From 2a74c9bcd6a467c7f2956512c675cc024ff527a7 Mon Sep 17 00:00:00 2001 From: Sai Saran Vaidyanathan Date: Tue, 29 Oct 2024 20:56:01 -0700 Subject: [PATCH 1/2] fix: for #557 --- internal/client/developers/subscriptions.go | 3 +-- internal/cmd/developers/crtsub.go | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/client/developers/subscriptions.go b/internal/client/developers/subscriptions.go index 12806d2aa..d025b58ef 100644 --- a/internal/client/developers/subscriptions.go +++ b/internal/client/developers/subscriptions.go @@ -21,7 +21,7 @@ import ( "strings" ) -func CreateSubscription(email string, name string, apiproduct string, startTime string, endTime string) (respBody []byte, err error) { +func CreateSubscription(email string, name string, apiproduct string, startTime string) (respBody []byte, err error) { u, _ := url.Parse(apiclient.GetApigeeBaseURL()) subscription := []string{} @@ -29,7 +29,6 @@ func CreateSubscription(email string, name string, apiproduct string, startTime subscription = append(subscription, "\"name\":\""+name+"\"") subscription = append(subscription, "\"apiproduct\":\""+apiproduct+"\"") subscription = append(subscription, "\"startTime\":\""+startTime+"\"") - subscription = append(subscription, "\"endTime\":\""+endTime+"\"") payload := "{" + strings.Join(subscription, ",") + "}" u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "developers", url.QueryEscape(email), "subscriptions") diff --git a/internal/cmd/developers/crtsub.go b/internal/cmd/developers/crtsub.go index ab8703afd..bf900203b 100644 --- a/internal/cmd/developers/crtsub.go +++ b/internal/cmd/developers/crtsub.go @@ -24,8 +24,8 @@ import ( // CreateSubCmd to create developer subscription var CreateSubCmd = &cobra.Command{ Use: "create", - Short: "Create a subcription for a developer", - Long: "Create a developer", + Short: "Create a subscription for a developer", + Long: "Create a subscription for a developer", Args: func(cmd *cobra.Command, args []string) (err error) { apiclient.SetRegion(region) return apiclient.SetApigeeOrg(org) @@ -33,12 +33,12 @@ var CreateSubCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) (err error) { cmd.SilenceUsage = true - _, err = developers.CreateSubscription(email, name, apiproduct, startTime, endTime) + _, err = developers.CreateSubscription(email, name, apiproduct, startTime) return }, } -var apiproduct, startTime, endTime string +var apiproduct, startTime string func init() { CreateSubCmd.Flags().StringVarP(&email, "email", "e", @@ -49,11 +49,8 @@ func init() { "", "The name of the API Product") CreateSubCmd.Flags().StringVarP(&startTime, "start", "s", "", "Subscription start time") - CreateSubCmd.Flags().StringVarP(&endTime, "end", "d", - "", "Subscription end time") _ = CreateSubCmd.MarkFlagRequired("email") _ = CreateSubCmd.MarkFlagRequired("apiproduct") _ = CreateSubCmd.MarkFlagRequired("start") - _ = CreateSubCmd.MarkFlagRequired("end") } From 218d1c5ee3f08c6df1b5735d6b099e556ad91a76 Mon Sep 17 00:00:00 2001 From: Sai Saran Vaidyanathan Date: Wed, 30 Oct 2024 07:52:45 -0700 Subject: [PATCH 2/2] fix: removed startTime and name --- internal/client/developers/subscriptions.go | 5 +---- internal/cmd/developers/crtsub.go | 9 ++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/internal/client/developers/subscriptions.go b/internal/client/developers/subscriptions.go index d025b58ef..75978866b 100644 --- a/internal/client/developers/subscriptions.go +++ b/internal/client/developers/subscriptions.go @@ -21,14 +21,11 @@ import ( "strings" ) -func CreateSubscription(email string, name string, apiproduct string, startTime string) (respBody []byte, err error) { +func CreateSubscription(email string, apiproduct string) (respBody []byte, err error) { u, _ := url.Parse(apiclient.GetApigeeBaseURL()) subscription := []string{} - - subscription = append(subscription, "\"name\":\""+name+"\"") subscription = append(subscription, "\"apiproduct\":\""+apiproduct+"\"") - subscription = append(subscription, "\"startTime\":\""+startTime+"\"") payload := "{" + strings.Join(subscription, ",") + "}" u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "developers", url.QueryEscape(email), "subscriptions") diff --git a/internal/cmd/developers/crtsub.go b/internal/cmd/developers/crtsub.go index bf900203b..b46a65a54 100644 --- a/internal/cmd/developers/crtsub.go +++ b/internal/cmd/developers/crtsub.go @@ -33,24 +33,19 @@ var CreateSubCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) (err error) { cmd.SilenceUsage = true - _, err = developers.CreateSubscription(email, name, apiproduct, startTime) + _, err = developers.CreateSubscription(email, apiproduct) return }, } -var apiproduct, startTime string +var apiproduct string func init() { CreateSubCmd.Flags().StringVarP(&email, "email", "e", "", "The developer's email") - CreateSubCmd.Flags().StringVarP(&name, "name", "n", - "", "The subscription name") CreateSubCmd.Flags().StringVarP(&apiproduct, "apiproduct", "p", "", "The name of the API Product") - CreateSubCmd.Flags().StringVarP(&startTime, "start", "s", - "", "Subscription start time") _ = CreateSubCmd.MarkFlagRequired("email") _ = CreateSubCmd.MarkFlagRequired("apiproduct") - _ = CreateSubCmd.MarkFlagRequired("start") }