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

Commit

Permalink
support staging orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Feb 2, 2021
1 parent 81f6036 commit f4bd626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apiclient/clifile.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func SetStaging(usestage bool) (err error) {
return WriteByteArrayToFile(path.Join(usr.HomeDir, apigeecliFile), false, data)
}

func GetStaging() bool {
return cliPref.Staging
}

func SetProxy(url string) (err error) {
if url == "" {
return nil
Expand Down
9 changes: 8 additions & 1 deletion client/orgs/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ func validRegion(region string) bool {
//Create
func Create(region string, network string, runtimeType string, databaseKey string) (respBody []byte, err error) {
const baseURL = "https://apigee.googleapis.com/v1/organizations"
var stageBaseURL = "https://staging-apigee.sandbox.googleapis.com/v1/organizations/"

if !validRegion(region) {
return respBody, fmt.Errorf("invalid analytics region."+
" Analytics region must be one of : %v", analyticsRegions)
}

u, _ := url.Parse(baseURL)
var u *url.URL
if apiclient.GetStaging() {
u, _ = url.Parse(stageBaseURL)
} else {
u, _ = url.Parse(baseURL)
}

u.Path = path.Join(u.Path)
q := u.Query()
q.Set("parent", "projects/"+apiclient.GetProjectID())
Expand Down

0 comments on commit f4bd626

Please sign in to comment.