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

bug: Create Developer Subscription #558

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions internal/client/developers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import (
"strings"
)

func CreateSubscription(email string, name string, apiproduct string, startTime string, endTime 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+"\"")
subscription = append(subscription, "\"endTime\":\""+endTime+"\"")

payload := "{" + strings.Join(subscription, ",") + "}"
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "developers", url.QueryEscape(email), "subscriptions")
Expand Down
16 changes: 4 additions & 12 deletions internal/cmd/developers/crtsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,28 @@ 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)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

_, err = developers.CreateSubscription(email, name, apiproduct, startTime, endTime)
_, err = developers.CreateSubscription(email, apiproduct)
return
},
}

var apiproduct, startTime, endTime 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.Flags().StringVarP(&endTime, "end", "d",
"", "Subscription end time")

_ = CreateSubCmd.MarkFlagRequired("email")
_ = CreateSubCmd.MarkFlagRequired("apiproduct")
_ = CreateSubCmd.MarkFlagRequired("start")
_ = CreateSubCmd.MarkFlagRequired("end")
}
Loading