Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
get api revision
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Feb 7, 2020
1 parent 7f8c057 commit df34097
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions client/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/apis/getapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ 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
},
}

func init() {
GetCmd.Flags().StringVarP(&name, "name", "n",
"", "API Proxy name")
GetCmd.Flags().IntVarP(&revision, "rev", "v",
-1, "API Proxy revision")

_ = GetCmd.MarkFlagRequired("name")
}

0 comments on commit df34097

Please sign in to comment.