From df340976f645fe8ea454954074dec8f2e938269b Mon Sep 17 00:00:00 2001 From: srinandan Date: Thu, 6 Feb 2020 21:24:31 -0800 Subject: [PATCH] get api revision --- client/apis/apis.go | 10 +++++++--- cmd/apis/getapi.go | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/apis/apis.go b/client/apis/apis.go index ecb1d2be..79dc9728 100644 --- a/client/apis/apis.go +++ b/client/apis/apis.go @@ -77,10 +77,14 @@ func FetchProxy(name string, revision int) (err error) { return apiclient.FetchBundle("apis", name, strconv.Itoa(revision)) } -//FetchProxy -func GetProxy(name string) (respBody []byte, err error) { +//GetProxy +func GetProxy(name string, revision int) (respBody []byte, err error) { u, _ := url.Parse(apiclient.BaseURL) - u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "apis", name) + if revision != -1 { + u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "apis", name, "revisions", strconv.Itoa(revision)) + } else { + u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "apis", name) + } respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String()) return respBody, err } diff --git a/cmd/apis/getapi.go b/cmd/apis/getapi.go index 3e00bfed..0776d55a 100644 --- a/cmd/apis/getapi.go +++ b/cmd/apis/getapi.go @@ -30,7 +30,7 @@ var GetCmd = &cobra.Command{ return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.GetProxy(name) + _, err = apis.GetProxy(name, revision) return }, } @@ -38,6 +38,8 @@ var GetCmd = &cobra.Command{ func init() { GetCmd.Flags().StringVarP(&name, "name", "n", "", "API Proxy name") + GetCmd.Flags().IntVarP(&revision, "rev", "v", + -1, "API Proxy revision") _ = GetCmd.MarkFlagRequired("name") }