Skip to content

Commit

Permalink
logic for expand
Browse files Browse the repository at this point in the history
  • Loading branch information
ssvaidyanathan committed Oct 24, 2024
1 parent 1796a43 commit 99f4068
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/client/products/rateplans.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ func GetRatePlan(productName string, rateplan string) (respBody []byte, err erro
}

// ListRatePlan
func ListRatePlan(productName string) (respBody []byte, err error) {
func ListRatePlan(productName string, expand bool) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.GetApigeeBaseURL())
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "apiproducts", productName, "rateplans")
q := u.Query()
q.Set("expand", "true")
if expand {
q.Set("expand", "true")
} else {
q.Set("expand", "false")
}
u.RawQuery = q.Encode()
respBody, err = apiclient.HttpClient(u.String())
return respBody, err
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/products/listrateplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ var ListRatePlanCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

_, err = products.ListRatePlan(apiproduct)
_, err = products.ListRatePlan(apiproduct, expand)
return
},
}

func init() {
ListRatePlanCmd.Flags().StringVarP(&apiproduct, "product", "p",
"", "name of the API Product")
ListRatePlanCmd.Flags().BoolVarP(&expand, "expand", "x",
false, "Expand Details")

_ = ListRatePlanCmd.MarkFlagRequired("product")
}

0 comments on commit 99f4068

Please sign in to comment.