Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rateplan issues #556

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions internal/client/products/rateplans.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ 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()
if expand {
q.Set("expand", "true")
srinandan marked this conversation as resolved.
Show resolved Hide resolved
} else {
q.Set("expand", "false")
}
u.RawQuery = q.Encode()
respBody, err = apiclient.HttpClient(u.String())
return respBody, err
}
Expand All @@ -56,7 +63,9 @@ func ListRatePlan(productName string) (respBody []byte, err error) {
func ExportRateplan(productName string) (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")
u.RawQuery = q.Encode()
// don't print to sysout
apiclient.ClientPrintHttpResponse.Set(false)
defer apiclient.ClientPrintHttpResponse.Set(apiclient.GetCmdPrintHttpResponseSetting())
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/products/crtrateplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ func init() {
CreateRateplanCmd.Flags().StringVarP(&rateplanFile, "rateplan", "",
"", "File containing Rate plane JSON. See samples for how to create the file")

_ = CreateRateplanCmd.MarkFlagRequired("apiproduct")
_ = CreateRateplanCmd.MarkFlagRequired("product")
_ = CreateRateplanCmd.MarkFlagRequired("rateplan")
}
10 changes: 5 additions & 5 deletions internal/cmd/products/delrateplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ var DelRatePlanCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

_, err = products.DeleteRatePlan(name, rateplan)
_, err = products.DeleteRatePlan(apiproduct, rateplan)
return
},
}

func init() {
DelRatePlanCmd.Flags().StringVarP(&name, "name", "n",
"", "name of the API Product")
DelRatePlanCmd.Flags().StringVarP(&rateplan, "rateplan", "p",
DelRatePlanCmd.Flags().StringVarP(&apiproduct, "product", "p",
"", "name of the API Product")
DelRatePlanCmd.Flags().StringVarP(&rateplan, "rateplan", "",
"", "Rate Plan Id")

_ = DelRatePlanCmd.MarkFlagRequired("name")
_ = DelRatePlanCmd.MarkFlagRequired("product")
_ = DelRatePlanCmd.MarkFlagRequired("rateplan")
}
8 changes: 4 additions & 4 deletions internal/cmd/products/exprateplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var ExpRateplanCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

exportFileName := "rateplan_" + name + ".json"
respBody, err := products.ExportRateplan(name)
exportFileName := "rateplan_" + apiproduct + ".json"
respBody, err := products.ExportRateplan(apiproduct)
if err != nil {
return err
}
Expand All @@ -43,8 +43,8 @@ var ExpRateplanCmd = &cobra.Command{
}

func init() {
ExpRateplanCmd.Flags().StringVarP(&name, "name", "n",
ExpRateplanCmd.Flags().StringVarP(&apiproduct, "product", "p",
"", "name of the API Product")

_ = ExpRateplanCmd.MarkFlagRequired("name")
_ = ExpRateplanCmd.MarkFlagRequired("product")
}
10 changes: 5 additions & 5 deletions internal/cmd/products/getrateplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ var GetRatePlanCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

_, err = products.GetRatePlan(name, rateplan)
_, err = products.GetRatePlan(apiproduct, rateplan)
return
},
}

func init() {
GetRatePlanCmd.Flags().StringVarP(&name, "name", "n",
"", "name of the API Product")
GetRatePlanCmd.Flags().StringVarP(&rateplan, "rateplan", "p",
GetRatePlanCmd.Flags().StringVarP(&apiproduct, "product", "p",
"", "name of the API Product")
GetRatePlanCmd.Flags().StringVarP(&rateplan, "rateplan", "",
"", "Rate Plan Id")

_ = GetRatePlanCmd.MarkFlagRequired("name")
_ = GetRatePlanCmd.MarkFlagRequired("product")
_ = GetRatePlanCmd.MarkFlagRequired("rateplan")
}
8 changes: 5 additions & 3 deletions 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(name)
_, err = products.ListRatePlan(apiproduct, expand)
return
},
}

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

_ = ListRatePlanCmd.MarkFlagRequired("name")
_ = ListRatePlanCmd.MarkFlagRequired("product")
}
1 change: 1 addition & 0 deletions internal/cmd/products/rateplans.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ func init() {
RatePlanCmd.AddCommand(ListRatePlanCmd)
RatePlanCmd.AddCommand(GetRatePlanCmd)
RatePlanCmd.AddCommand(DelRatePlanCmd)
RatePlanCmd.AddCommand(ExpRateplanCmd)
}
Loading