Skip to content

Commit c23ffa9

Browse files
Apigee organization (#4317) (#2856)
* Apigee organization * fix import, workaround beta test MM bug Signed-off-by: Modular Magician <[email protected]>
1 parent b9ae926 commit c23ffa9

File tree

9 files changed

+1227
-2
lines changed

9 files changed

+1227
-2
lines changed

.changelog/4317.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
apigee_organization
3+
```

google-beta/apigee_operation.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
package google
15+
16+
import (
17+
"encoding/json"
18+
"fmt"
19+
"time"
20+
)
21+
22+
type ApigeeOperationWaiter struct {
23+
Config *Config
24+
UserAgent string
25+
CommonOperationWaiter
26+
}
27+
28+
func (w *ApigeeOperationWaiter) QueryOp() (interface{}, error) {
29+
if w == nil {
30+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
31+
}
32+
// Returns the proper get.
33+
url := fmt.Sprintf("https://apigee.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)
34+
35+
return sendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
36+
}
37+
38+
func createApigeeWaiter(config *Config, op map[string]interface{}, activity, userAgent string) (*ApigeeOperationWaiter, error) {
39+
if val, ok := op["name"]; !ok || val == "" {
40+
// An operation could also be indicated with a "metadata" field.
41+
if _, ok := op["metadata"]; !ok {
42+
// This was a synchronous call - there is no operation to wait for.
43+
return nil, nil
44+
}
45+
}
46+
w := &ApigeeOperationWaiter{
47+
Config: config,
48+
UserAgent: userAgent,
49+
}
50+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
51+
return nil, err
52+
}
53+
return w, nil
54+
}
55+
56+
// nolint: deadcode,unused
57+
func apigeeOperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
58+
w, err := createApigeeWaiter(config, op, activity, userAgent)
59+
if err != nil || w == nil {
60+
// If w is nil, the op was synchronous.
61+
return err
62+
}
63+
if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil {
64+
return err
65+
}
66+
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
67+
}
68+
69+
func apigeeOperationWaitTime(config *Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
70+
w, err := createApigeeWaiter(config, op, activity, userAgent)
71+
if err != nil || w == nil {
72+
// If w is nil, the op was synchronous.
73+
return err
74+
}
75+
return OperationWait(w, activity, timeout, config.PollInterval)
76+
}

google-beta/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type Config struct {
8787
AccessContextManagerBasePath string
8888
ActiveDirectoryBasePath string
8989
ApiGatewayBasePath string
90+
ApigeeBasePath string
9091
AppEngineBasePath string
9192
ArtifactRegistryBasePath string
9293
BigQueryBasePath string
@@ -174,6 +175,7 @@ var AccessApprovalDefaultBasePath = "https://accessapproval.googleapis.com/v1/"
174175
var AccessContextManagerDefaultBasePath = "https://accesscontextmanager.googleapis.com/v1/"
175176
var ActiveDirectoryDefaultBasePath = "https://managedidentities.googleapis.com/v1/"
176177
var ApiGatewayDefaultBasePath = "https://apigateway.googleapis.com/v1beta/"
178+
var ApigeeDefaultBasePath = "https://apigee.googleapis.com/v1/"
177179
var AppEngineDefaultBasePath = "https://appengine.googleapis.com/v1/"
178180
var ArtifactRegistryDefaultBasePath = "https://artifactregistry.googleapis.com/v1beta1/"
179181
var BigQueryDefaultBasePath = "https://bigquery.googleapis.com/bigquery/v2/"
@@ -971,6 +973,7 @@ func ConfigureBasePaths(c *Config) {
971973
c.AccessContextManagerBasePath = AccessContextManagerDefaultBasePath
972974
c.ActiveDirectoryBasePath = ActiveDirectoryDefaultBasePath
973975
c.ApiGatewayBasePath = ApiGatewayDefaultBasePath
976+
c.ApigeeBasePath = ApigeeDefaultBasePath
974977
c.AppEngineBasePath = AppEngineDefaultBasePath
975978
c.ArtifactRegistryBasePath = ArtifactRegistryDefaultBasePath
976979
c.BigQueryBasePath = BigQueryDefaultBasePath

google-beta/provider.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ func Provider() *schema.Provider {
167167
"GOOGLE_API_GATEWAY_CUSTOM_ENDPOINT",
168168
}, ApiGatewayDefaultBasePath),
169169
},
170+
"apigee_custom_endpoint": {
171+
Type: schema.TypeString,
172+
Optional: true,
173+
ValidateFunc: validateCustomEndpoint,
174+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
175+
"GOOGLE_APIGEE_CUSTOM_ENDPOINT",
176+
}, ApigeeDefaultBasePath),
177+
},
170178
"app_engine_custom_endpoint": {
171179
Type: schema.TypeString,
172180
Optional: true,
@@ -781,9 +789,9 @@ func Provider() *schema.Provider {
781789
return provider
782790
}
783791

784-
// Generated resources: 205
792+
// Generated resources: 206
785793
// Generated IAM resources: 105
786-
// Total generated resources: 310
794+
// Total generated resources: 311
787795
func ResourceMap() map[string]*schema.Resource {
788796
resourceMap, _ := ResourceMapWithErrors()
789797
return resourceMap
@@ -817,6 +825,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
817825
"google_api_gateway_gateway_iam_binding": ResourceIamBinding(ApiGatewayGatewayIamSchema, ApiGatewayGatewayIamUpdaterProducer, ApiGatewayGatewayIdParseFunc),
818826
"google_api_gateway_gateway_iam_member": ResourceIamMember(ApiGatewayGatewayIamSchema, ApiGatewayGatewayIamUpdaterProducer, ApiGatewayGatewayIdParseFunc),
819827
"google_api_gateway_gateway_iam_policy": ResourceIamPolicy(ApiGatewayGatewayIamSchema, ApiGatewayGatewayIamUpdaterProducer, ApiGatewayGatewayIdParseFunc),
828+
"google_apigee_organization": resourceApigeeOrganization(),
820829
"google_app_engine_domain_mapping": resourceAppEngineDomainMapping(),
821830
"google_app_engine_firewall_rule": resourceAppEngineFirewallRule(),
822831
"google_app_engine_standard_app_version": resourceAppEngineStandardAppVersion(),
@@ -1295,6 +1304,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
12951304
config.AccessContextManagerBasePath = d.Get("access_context_manager_custom_endpoint").(string)
12961305
config.ActiveDirectoryBasePath = d.Get("active_directory_custom_endpoint").(string)
12971306
config.ApiGatewayBasePath = d.Get("api_gateway_custom_endpoint").(string)
1307+
config.ApigeeBasePath = d.Get("apigee_custom_endpoint").(string)
12981308
config.AppEngineBasePath = d.Get("app_engine_custom_endpoint").(string)
12991309
config.ArtifactRegistryBasePath = d.Get("artifact_registry_custom_endpoint").(string)
13001310
config.BigQueryBasePath = d.Get("big_query_custom_endpoint").(string)

0 commit comments

Comments
 (0)