Skip to content

Commit

Permalink
Apigee organization (hashicorp#4317)
Browse files Browse the repository at this point in the history
* Apigee organization

* fix import, workaround beta test MM bug

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Jan 12, 2021
1 parent ee8ce0f commit 2f35690
Show file tree
Hide file tree
Showing 9 changed files with 1,084 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/4317.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
apigee_organization
```
76 changes: 76 additions & 0 deletions google/apigee_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google

import (
"encoding/json"
"fmt"
"time"
)

type ApigeeOperationWaiter struct {
Config *Config
UserAgent string
CommonOperationWaiter
}

func (w *ApigeeOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("https://apigee.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)

return sendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
}

func createApigeeWaiter(config *Config, op map[string]interface{}, activity, userAgent string) (*ApigeeOperationWaiter, error) {
if val, ok := op["name"]; !ok || val == "" {
// An operation could also be indicated with a "metadata" field.
if _, ok := op["metadata"]; !ok {
// This was a synchronous call - there is no operation to wait for.
return nil, nil
}
}
w := &ApigeeOperationWaiter{
Config: config,
UserAgent: userAgent,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func apigeeOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
w, err := createApigeeWaiter(config, op, activity, userAgent)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func apigeeOperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
w, err := createApigeeWaiter(config, op, activity, userAgent)
if err != nil || w == nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeout, config.PollInterval)
}
3 changes: 3 additions & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Config struct {
AccessApprovalBasePath string
AccessContextManagerBasePath string
ActiveDirectoryBasePath string
ApigeeBasePath string
AppEngineBasePath string
BigQueryBasePath string
BigqueryDataTransferBasePath string
Expand Down Expand Up @@ -164,6 +165,7 @@ type Config struct {
var AccessApprovalDefaultBasePath = "https://accessapproval.googleapis.com/v1/"
var AccessContextManagerDefaultBasePath = "https://accesscontextmanager.googleapis.com/v1/"
var ActiveDirectoryDefaultBasePath = "https://managedidentities.googleapis.com/v1/"
var ApigeeDefaultBasePath = "https://apigee.googleapis.com/v1/"
var AppEngineDefaultBasePath = "https://appengine.googleapis.com/v1/"
var BigQueryDefaultBasePath = "https://bigquery.googleapis.com/bigquery/v2/"
var BigqueryDataTransferDefaultBasePath = "https://bigquerydatatransfer.googleapis.com/v1/"
Expand Down Expand Up @@ -952,6 +954,7 @@ func ConfigureBasePaths(c *Config) {
c.AccessApprovalBasePath = AccessApprovalDefaultBasePath
c.AccessContextManagerBasePath = AccessContextManagerDefaultBasePath
c.ActiveDirectoryBasePath = ActiveDirectoryDefaultBasePath
c.ApigeeBasePath = ApigeeDefaultBasePath
c.AppEngineBasePath = AppEngineDefaultBasePath
c.BigQueryBasePath = BigQueryDefaultBasePath
c.BigqueryDataTransferBasePath = BigqueryDataTransferDefaultBasePath
Expand Down
14 changes: 12 additions & 2 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ func Provider() *schema.Provider {
"GOOGLE_ACTIVE_DIRECTORY_CUSTOM_ENDPOINT",
}, ActiveDirectoryDefaultBasePath),
},
"apigee_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_APIGEE_CUSTOM_ENDPOINT",
}, ApigeeDefaultBasePath),
},
"app_engine_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -705,9 +713,9 @@ func Provider() *schema.Provider {
return provider
}

// Generated resources: 180
// Generated resources: 181
// Generated IAM resources: 75
// Total generated resources: 255
// Total generated resources: 256
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand All @@ -729,6 +737,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_access_context_manager_gcp_user_access_binding": resourceAccessContextManagerGcpUserAccessBinding(),
"google_active_directory_domain": resourceActiveDirectoryDomain(),
"google_active_directory_domain_trust": resourceActiveDirectoryDomainTrust(),
"google_apigee_organization": resourceApigeeOrganization(),
"google_app_engine_domain_mapping": resourceAppEngineDomainMapping(),
"google_app_engine_firewall_rule": resourceAppEngineFirewallRule(),
"google_app_engine_standard_app_version": resourceAppEngineStandardAppVersion(),
Expand Down Expand Up @@ -1160,6 +1169,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.AccessApprovalBasePath = d.Get("access_approval_custom_endpoint").(string)
config.AccessContextManagerBasePath = d.Get("access_context_manager_custom_endpoint").(string)
config.ActiveDirectoryBasePath = d.Get("active_directory_custom_endpoint").(string)
config.ApigeeBasePath = d.Get("apigee_custom_endpoint").(string)
config.AppEngineBasePath = d.Get("app_engine_custom_endpoint").(string)
config.BigQueryBasePath = d.Get("big_query_custom_endpoint").(string)
config.BigqueryDataTransferBasePath = d.Get("bigquery_data_transfer_custom_endpoint").(string)
Expand Down
Loading

0 comments on commit 2f35690

Please sign in to comment.