diff --git a/client/orgs/orgs.go b/client/orgs/orgs.go index ee3d23af..364e0eb5 100644 --- a/client/orgs/orgs.go +++ b/client/orgs/orgs.go @@ -68,7 +68,7 @@ func validRegion(region string) bool { } //Create -func Create(region string, network string, runtimeType string, databaseKey string) (respBody []byte, err error) { +func Create(region string, network string, runtimeType string, databaseKey string, billingType string) (respBody []byte, err error) { const baseURL = "https://apigee.googleapis.com/v1/organizations" var stageBaseURL = "https://staging-apigee.sandbox.googleapis.com/v1/organizations/" @@ -98,6 +98,10 @@ func Create(region string, network string, runtimeType string, databaseKey strin orgPayload = append(orgPayload, "\"runtimeDatabaseEncryptionKeyName\":\""+databaseKey+"\"") } + if billingType != "" { + orgPayload = append(orgPayload, "\"billingType\":\""+billingType+"\"") + } + payload := "{" + strings.Join(orgPayload, ",") + "}" respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), payload) return respBody, err diff --git a/cmd/org/createorg.go b/cmd/org/createorg.go index 3bfb0e14..8ff855a6 100644 --- a/cmd/org/createorg.go +++ b/cmd/org/createorg.go @@ -31,6 +31,11 @@ var CreateCmd = &cobra.Command{ if runtimeType != "HYBRID" && runtimeType != "CLOUD" { return fmt.Errorf("runtime type must be CLOUD or HYBRID") } + + if billingType != "SUBSCRIPTION" && billingType != "EVALUATION" { + return fmt.Errorf("Billing type must be SUBSCRIPTION or EVALUATION") + } + if runtimeType == "CLOUD" { if network == "" { return fmt.Errorf("authorized network must be supplied") @@ -43,12 +48,12 @@ var CreateCmd = &cobra.Command{ return apiclient.SetApigeeOrg(projectID) }, RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = orgs.Create(region, network, runtimeType, databaseKey) + _, err = orgs.Create(region, network, runtimeType, databaseKey, billingType) return }, } -var region, projectID, network, runtimeType, description, databaseKey string +var region, projectID, network, runtimeType, description, databaseKey, billingType string func init() { @@ -64,6 +69,8 @@ func init() { "", "Runtime Database Encryption Key") CreateCmd.Flags().StringVarP(&runtimeType, "runtime-type", "", "HYBRID", "Runtime type: CLOUD or HYBRID") + CreateCmd.Flags().StringVarP(&runtimeType, "billing-type", "", + "", "Billing type: SUBSCRIPTION or EVALUATION") _ = CreateCmd.MarkFlagRequired("prj") _ = CreateCmd.MarkFlagRequired("reg") diff --git a/cmd/overrides/apply.go b/cmd/overrides/apply.go index a35da251..c206f15a 100644 --- a/cmd/overrides/apply.go +++ b/cmd/overrides/apply.go @@ -46,7 +46,7 @@ var ApplyCmd = &cobra.Command{ //check if the org exists if _, err = orgs.Get(); err != nil { - if _, err = orgs.Create(getOrgRegion(), "", "HYBRID", ""); err != nil { + if _, err = orgs.Create(getOrgRegion(), "", "HYBRID", "", ""); err != nil { return err } fmt.Printf("Org %s created\n", getOrg())