This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
srinandan
committed
Oct 26, 2019
1 parent
03ffa69
commit 98e5690
Showing
16 changed files
with
502 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package crttrcapi | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"net/url" | ||
"path" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to manage tracing of apis | ||
var Cmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create a new debug session for an API proxy", | ||
Long: "Create a new debug session for Apigee API proxy revision deployed in an environment", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
u, _ := url.Parse(shared.BaseURL) | ||
u.Path = path.Join(u.Path, shared.RootArgs.Org, "environments", shared.RootArgs.Env, "apis", name, "revisions", revision, "debugsessions") | ||
q := u.Query() | ||
q.Set("timeout", "567") | ||
u.RawQuery = q.Encode() | ||
|
||
var payload = "" | ||
if len(filter) != 0 { | ||
payload = "{\"filter\":" + getFilterStr() + "}" | ||
} else { | ||
payload = "{}" | ||
} | ||
_, err = shared.HttpClient(true, u.String(), payload) | ||
return | ||
|
||
}, | ||
} | ||
|
||
var name, revision string | ||
var filter map[string]string | ||
|
||
func init() { | ||
|
||
Cmd.Flags().StringVarP(&name, "name", "n", | ||
"", "API proxy name") | ||
Cmd.Flags().StringVarP(&revision, "rev", "v", | ||
"", "API Proxy revision") | ||
Cmd.Flags().StringToStringVar(&filter, "filter", | ||
nil, "Filter Conditions; format is name1=value1,name2=value2...") | ||
|
||
_ = Cmd.MarkFlagRequired("name") | ||
_ = Cmd.MarkFlagRequired("rev") | ||
|
||
} | ||
|
||
func getFilterStr() string { | ||
b := new(bytes.Buffer) | ||
for key, value := range filter { | ||
fmt.Fprintf(b, "%s=\"%s\"\n", key, value) | ||
} | ||
return b.String() | ||
} |
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,50 @@ | ||
package gettrcapi | ||
|
||
import ( | ||
"net/url" | ||
"path" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to manage tracing of apis | ||
var Cmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get a debug session for an API proxy revision", | ||
Long: "Get a debug session for an API proxy revision deployed in an environment", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
u, _ := url.Parse(shared.BaseURL) | ||
if messageID == "" { | ||
u.Path = path.Join(u.Path, shared.RootArgs.Org, "environments", shared.RootArgs.Env, "apis", name, "revisions", revision, "debugsessions", sessionID, "data") | ||
q := u.Query() | ||
q.Set("limit", "20") | ||
u.RawQuery = q.Encode() | ||
} else { | ||
u.Path = path.Join(u.Path, shared.RootArgs.Org, "environments", shared.RootArgs.Env, "apis", name, "revisions", revision, "debugsessions", sessionID, "data", messageID) | ||
} | ||
|
||
_, err = shared.HttpClient(true, u.String()) | ||
return | ||
|
||
}, | ||
} | ||
|
||
var name, revision, sessionID, messageID string | ||
|
||
func init() { | ||
|
||
Cmd.Flags().StringVarP(&name, "name", "n", | ||
"", "API proxy name") | ||
Cmd.Flags().StringVarP(&revision, "rev", "v", | ||
"", "API Proxy revision") | ||
Cmd.Flags().StringVarP(&sessionID, "ses", "s", | ||
"", "Debug session Id") | ||
Cmd.Flags().StringVarP(&messageID, "msg", "m", | ||
"", "Debug session Id") | ||
|
||
_ = Cmd.MarkFlagRequired("name") | ||
_ = Cmd.MarkFlagRequired("rev") | ||
_ = Cmd.MarkFlagRequired("ses") | ||
|
||
} |
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 @@ | ||
package listtrcapi | ||
|
||
import ( | ||
"net/url" | ||
"path" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to manage tracing of apis | ||
var Cmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List all debug sessions for an API proxy revision", | ||
Long: "List all debug sessions for an API proxy revision deployed in an environment", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
u, _ := url.Parse(shared.BaseURL) | ||
u.Path = path.Join(u.Path, shared.RootArgs.Org, "environments", shared.RootArgs.Env, "apis", name, "revisions", revision, "debugsessions") | ||
_, err = shared.HttpClient(true, u.String()) | ||
return | ||
|
||
}, | ||
} | ||
|
||
var name, revision string | ||
|
||
func init() { | ||
|
||
Cmd.Flags().StringVarP(&name, "name", "n", | ||
"", "API proxy name") | ||
Cmd.Flags().StringVarP(&revision, "rev", "v", | ||
"", "API Proxy revision") | ||
|
||
_ = Cmd.MarkFlagRequired("name") | ||
_ = Cmd.MarkFlagRequired("rev") | ||
|
||
} |
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,28 @@ | ||
package apis | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/apis/traceapi/crttrcapi" | ||
"github.com/srinandan/apigeecli/cmd/apis/traceapi/gettrcapi" | ||
"github.com/srinandan/apigeecli/cmd/apis/traceapi/listtrcapi" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to manage tracing of apis | ||
var Cmd = &cobra.Command{ | ||
Use: "trace", | ||
Short: "Manage debugging/tracing of Apigee API proxies", | ||
Long: "Manage debugging/tracing of Apigee API proxy revisions deployed in an environment", | ||
} | ||
|
||
func init() { | ||
|
||
Cmd.PersistentFlags().StringVarP(&shared.RootArgs.Env, "env", "e", | ||
"", "Apigee environment name") | ||
|
||
_ = Cmd.MarkPersistentFlagRequired("env") | ||
|
||
Cmd.AddCommand(crttrcapi.Cmd) | ||
Cmd.AddCommand(listtrcapi.Cmd) | ||
Cmd.AddCommand(gettrcapi.Cmd) | ||
} |
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,30 @@ | ||
package cache | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/cache/delcache" | ||
"github.com/srinandan/apigeecli/cmd/cache/listcache" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to manage tracing of apis | ||
var Cmd = &cobra.Command{ | ||
Use: "cache", | ||
Short: "Manage caches within an Apigee environment", | ||
Long: "Manage caches within an Apigee environment", | ||
} | ||
|
||
func init() { | ||
|
||
Cmd.PersistentFlags().StringVarP(&shared.RootArgs.Org, "org", "o", | ||
"", "Apigee organization name") | ||
|
||
Cmd.PersistentFlags().StringVarP(&shared.RootArgs.Env, "env", "e", | ||
"", "Apigee environment name") | ||
|
||
_ = Cmd.MarkPersistentFlagRequired("org") | ||
_ = Cmd.MarkPersistentFlagRequired("env") | ||
|
||
Cmd.AddCommand(listcache.Cmd) | ||
Cmd.AddCommand(delcache.Cmd) | ||
} |
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,34 @@ | ||
package delcache | ||
|
||
import ( | ||
"net/url" | ||
"path" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/srinandan/apigeecli/cmd/shared" | ||
) | ||
|
||
//Cmd to delete cache | ||
var Cmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete a cache resource from the environment", | ||
Long: "Delete a cache resource from the environment", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
u, _ := url.Parse(shared.BaseURL) | ||
u.Path = path.Join(u.Path, shared.RootArgs.Org, "environments", shared.RootArgs.Env, "caches", name) | ||
_, err = shared.HttpClient(true, u.String()) | ||
return | ||
|
||
}, | ||
} | ||
|
||
var name string | ||
|
||
func init() { | ||
|
||
Cmd.Flags().StringVarP(&name, "name", "n", | ||
"", "API proxy name") | ||
|
||
_ = Cmd.MarkFlagRequired("name") | ||
|
||
} |
Oops, something went wrong.