Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
support billing type
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jan 23, 2022
1 parent ebca1d7 commit 762fd71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion client/orgs/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions cmd/org/createorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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() {

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/overrides/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 762fd71

Please sign in to comment.