From 68791b55ef41ac9160997cb20e117b55aca8116f Mon Sep 17 00:00:00 2001 From: timwillsie Date: Fri, 11 Jul 2014 21:47:36 +0200 Subject: [PATCH 1/2] implemented "show trace view" feature to open the trace view of a deployed proxy in browser --- Default.sublime-commands | 4 ++ .../deploy_vars.json | 3 +- .../deploy_vars.json | 3 +- .../Apigee Proxy/deploy_vars.json | 3 +- Readme.md | 10 ++++- ShowTrace.py | 37 +++++++++++++++++++ 6 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 ShowTrace.py diff --git a/Default.sublime-commands b/Default.sublime-commands index 7506fde..4994314 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -24,6 +24,10 @@ { "caption":"Apigee: Add Flow to Proxy", "command":"add_flow" + }, + { + "caption":"Apigee: Show Trace (opens in browser)", + "command":"show_trace" } ] diff --git a/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs - usergrid (Work in Progress)/deploy_vars.json b/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs - usergrid (Work in Progress)/deploy_vars.json index b74523a..27b9449 100644 --- a/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs - usergrid (Work in Progress)/deploy_vars.json +++ b/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs - usergrid (Work in Progress)/deploy_vars.json @@ -4,6 +4,7 @@ "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)" -} \ No newline at end of file +} diff --git a/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs/deploy_vars.json b/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs/deploy_vars.json index b74523a..27b9449 100644 --- a/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs/deploy_vars.json +++ b/ProjectTemplates/Apigee Proxy - NodeJs with ExpressJs/deploy_vars.json @@ -4,6 +4,7 @@ "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)" -} \ No newline at end of file +} diff --git a/ProjectTemplates/Apigee Proxy/deploy_vars.json b/ProjectTemplates/Apigee Proxy/deploy_vars.json index b74523a..27b9449 100644 --- a/ProjectTemplates/Apigee Proxy/deploy_vars.json +++ b/ProjectTemplates/Apigee Proxy/deploy_vars.json @@ -4,6 +4,7 @@ "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)" -} \ No newline at end of file +} diff --git a/Readme.md b/Readme.md index 038d8b6..7ee92d6 100644 --- a/Readme.md +++ b/Readme.md @@ -24,7 +24,7 @@ OSX > `git clone git@github.com:apigee/Sweetlime.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ApigeeSweetLime' Windows -> coming soon (testing underway) +> `git clone git@github.com:apigee/Sweetlime.git %APPDATA%\Sublime Text 3\Packages\ApigeeSweetLime' ##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/:api/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 \ No newline at end of file + [1]: https://github.com/apigee/api-platform-tools diff --git a/ShowTrace.py b/ShowTrace.py new file mode 100644 index 0000000..c195d98 --- /dev/null +++ b/ShowTrace.py @@ -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 From 15c51f535573edd13c5e7d321bf7cca78a30cdd1 Mon Sep 17 00:00:00 2001 From: timwillsie Date: Fri, 11 Jul 2014 22:13:22 +0200 Subject: [PATCH 2/2] corrected param for trace_uri example in Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 7ee92d6..36c3bbc 100644 --- a/Readme.md +++ b/Readme.md @@ -88,7 +88,7 @@ keyring.set_password("orgname", "username", "password") 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/:api/1?section=trace") +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