This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
implemented "show trace view" feature to open the trace view in browser #4
Open
timwillsie
wants to merge
2
commits into
apigee:master
Choose a base branch
from
timwillsie:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ OSX | |
> `git clone [email protected]:apigee/Sweetlime.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ApigeeSweetLime' | ||
|
||
Windows | ||
> coming soon (testing underway) | ||
> `git clone [email protected]:apigee/Sweetlime.git %APPDATA%\Sublime Text 3\Packages\ApigeeSweetLime' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. works in Windows too? thats great! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, at least with windows 7 and the latest sublime text 3 version. Unfortunately I have no chance to test this on windows 8. But I think it's a good idea to give the installation advice in the readme, so anyone with windows 8 has any clue how to test it and open an issue if it doesn't work. |
||
|
||
##Using SweetLime | ||
|
||
|
@@ -41,6 +41,8 @@ Adds a policy step - existing and new. | |
Creates a new policy from a list of policy templates. | ||
###Apigee: Fetch Policy Templates | ||
Fetches a policy template to a file. | ||
###Apigee: Show Trace (opens in browser) | ||
Opens the trace view of a deployed proxy in a new browser tab | ||
|
||
[Video: Developing proxies for Apigee Edge](https://www.youtube.com/watch?v=TMVIEFuQr7k) | ||
|
||
|
@@ -62,6 +64,7 @@ Proxies created with SweetLime include a JSON file called `deploy_vars.json` wit | |
"username":"USERNAME", | ||
"password":"PASSWORD (OPTIONAL)", | ||
"uri":"MGMT SERVER URL(OPTIONAL)", | ||
"trace_uri":""https://enterprise.apigee.com/platform/#/:org/apis/:proxy/1?section=trace"", | ||
"displayname":"DISPLAY NAME (OPTIONAL)", | ||
"basepath":"BASEPATH (OPTIONAL)" | ||
} | ||
|
@@ -84,6 +87,9 @@ keyring.set_password("orgname", "username", "password") | |
###uri - optional | ||
If your deploy destination is Apigee cloud then leave this empty, else provide the url to the management server on your OPDK installation | ||
|
||
###trace_uri - optional | ||
If your deploy destination is Apigee cloud then leave as-is, else provide the url to the management server on your OPDK installation. Use ":org" and ":proxy" as placeholders for organization and proxy name (e.g. "https://apigee.mycompany.com/platform/#/:org/apis/:proxy/1?section=trace") | ||
|
||
###displayname - optional | ||
If displayname is not provided, it will be defaulted to the proxy name | ||
|
||
|
@@ -110,4 +116,4 @@ The above copyright notice and this permission notice shall be included in all c | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
|
||
[1]: https://github.com/apigee/api-platform-tools | ||
[1]: https://github.com/apigee/api-platform-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os, time, re | ||
import sublime | ||
import sublime_plugin | ||
import glob | ||
import json | ||
import webbrowser | ||
from pprint import pprint | ||
|
||
current_path = None | ||
|
||
class ShowTraceCommand(sublime_plugin.WindowCommand): | ||
|
||
|
||
def run(self): | ||
|
||
if not self.find_root(): | ||
return | ||
|
||
proxy = os.path.basename(self.root) | ||
json_data = open(self.root + '/deploy_vars.json') | ||
data = json.load(json_data) | ||
json_data.close() | ||
|
||
new = 2 # open in a new tab, if possible | ||
url = data['trace_uri'].replace(':org',data['org']).replace(':proxy', proxy) | ||
|
||
webbrowser.open(url,new=new) | ||
|
||
def find_root(self): | ||
folders = self.window.folders() | ||
if len(folders) == 0: | ||
sublime.error_message('Could not find project root') | ||
return False | ||
|
||
self.root = folders[0] | ||
self.rel_path_start = len(self.root) + 1 | ||
return True |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of things here
"trace_uri":"TRACE URL(OPTIONAL)".
If the user provides a url then we use that instead of the enterprise one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey girish.
oh my, i totally oversaw the "/1" in the url! Thanks for pointing that out!
What would be the preferable way to determine the revision? Ask the user for it or use the management api (http://apigee.com/docs/api/get-api-proxy) to fetch the list of revisions and let the user choose one?
The latter would give a chance to quit with an error message before launching the browser if the proxy hasn't been deployed yet.
Where would you put the default url? Hard coding it in ShowTrace.py sounds dirty to me. Is SweetLime.sublime-settings a good place for that? That would enable a team of OPDK in-house developers to use Sweetlime as-is and share the settings among team members so they only have to configure the url once and not in every deploy.vars file...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Tim,
On point 2), using .sublime-settings is the best solution. Please go ahead with that.
On point 1), If at all possible I would avoid hitting the mgmt api again. For deploying the proxy I rely on
apigeetool deployproxy
source: https://github.com/apigee/api-platform-tools/blob/master/ApigeePlatformTools/deployproxy.py. Upon a successful deploy, the deployproxy.py script throws up, along with other stuff like proxy-name, env, etc, also the revision number. However it is a part of a success message that goes something like this: Proxy: "myAwesomeProxy" Revision 1.While a dirty way would be to fallback on string manipulation to fetch the revision, the cleaner way would be to make changes to deployproxy.py such that we get the revision number explicitly.
Girish
If all this doesnt work for whatever reason then we just fall back on the mgmt api call.