Skip to content

Commit

Permalink
Add support for Beyondcorp AppConnector resource (#6801) (#13011)
Browse files Browse the repository at this point in the history
* Add support for Beyondcorp AppConnector resource

* Disabling IAM policy until policy bindings are fixed

* Adding support for Beyondcorp AppGateway resource

* 1. Addressing PR comments
2. Setting appGateway resoruce to be non updatable.
3. Added a test to verify update/patch ot app connector

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 10, 2022
1 parent 061f418 commit 6771e71
Show file tree
Hide file tree
Showing 13 changed files with 1,932 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changelog/6801.txt
@@ -0,0 +1,6 @@
```release-note:new-resource
`google_beyondcorp_app_connector`
```
```release-note:new-resource
`google_beyondcorp_app_gateway`
```
75 changes: 75 additions & 0 deletions google/beyondcorp_operation.go
@@ -0,0 +1,75 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// 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 BeyondcorpOperationWaiter struct {
Config *Config
UserAgent string
Project string
CommonOperationWaiter
}

func (w *BeyondcorpOperationWaiter) 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("%s%s", w.Config.BeyondcorpBasePath, w.CommonOperationWaiter.Op.Name)

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

func createBeyondcorpWaiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*BeyondcorpOperationWaiter, error) {
w := &BeyondcorpOperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

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

func beyondcorpOperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createBeyondcorpWaiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeout, config.PollInterval)
}
4 changes: 4 additions & 0 deletions google/config.go
Expand Up @@ -177,6 +177,7 @@ type Config struct {
ApigeeBasePath string
AppEngineBasePath string
ArtifactRegistryBasePath string
BeyondcorpBasePath string
BigQueryBasePath string
BigqueryAnalyticsHubBasePath string
BigqueryConnectionBasePath string
Expand Down Expand Up @@ -274,6 +275,7 @@ const ActiveDirectoryBasePathKey = "ActiveDirectory"
const ApigeeBasePathKey = "Apigee"
const AppEngineBasePathKey = "AppEngine"
const ArtifactRegistryBasePathKey = "ArtifactRegistry"
const BeyondcorpBasePathKey = "Beyondcorp"
const BigQueryBasePathKey = "BigQuery"
const BigqueryAnalyticsHubBasePathKey = "BigqueryAnalyticsHub"
const BigqueryConnectionBasePathKey = "BigqueryConnection"
Expand Down Expand Up @@ -365,6 +367,7 @@ var DefaultBasePaths = map[string]string{
ApigeeBasePathKey: "https://apigee.googleapis.com/v1/",
AppEngineBasePathKey: "https://appengine.googleapis.com/v1/",
ArtifactRegistryBasePathKey: "https://artifactregistry.googleapis.com/v1/",
BeyondcorpBasePathKey: "https://beyondcorp.googleapis.com/v1/",
BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/",
BigqueryAnalyticsHubBasePathKey: "https://analyticshub.googleapis.com/v1/",
BigqueryConnectionBasePathKey: "https://bigqueryconnection.googleapis.com/v1/",
Expand Down Expand Up @@ -1218,6 +1221,7 @@ func ConfigureBasePaths(c *Config) {
c.ApigeeBasePath = DefaultBasePaths[ApigeeBasePathKey]
c.AppEngineBasePath = DefaultBasePaths[AppEngineBasePathKey]
c.ArtifactRegistryBasePath = DefaultBasePaths[ArtifactRegistryBasePathKey]
c.BeyondcorpBasePath = DefaultBasePaths[BeyondcorpBasePathKey]
c.BigQueryBasePath = DefaultBasePaths[BigQueryBasePathKey]
c.BigqueryAnalyticsHubBasePath = DefaultBasePaths[BigqueryAnalyticsHubBasePathKey]
c.BigqueryConnectionBasePath = DefaultBasePaths[BigqueryConnectionBasePathKey]
Expand Down
15 changes: 13 additions & 2 deletions google/provider.go
Expand Up @@ -197,6 +197,14 @@ func Provider() *schema.Provider {
"GOOGLE_ARTIFACT_REGISTRY_CUSTOM_ENDPOINT",
}, DefaultBasePaths[ArtifactRegistryBasePathKey]),
},
"beyondcorp_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_BEYONDCORP_CUSTOM_ENDPOINT",
}, DefaultBasePaths[BeyondcorpBasePathKey]),
},
"big_query_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -917,9 +925,9 @@ func Provider() *schema.Provider {
return provider
}

// Generated resources: 246
// Generated resources: 248
// Generated IAM resources: 150
// Total generated resources: 396
// Total generated resources: 398
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -966,6 +974,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_artifact_registry_repository_iam_binding": ResourceIamBinding(ArtifactRegistryRepositoryIamSchema, ArtifactRegistryRepositoryIamUpdaterProducer, ArtifactRegistryRepositoryIdParseFunc),
"google_artifact_registry_repository_iam_member": ResourceIamMember(ArtifactRegistryRepositoryIamSchema, ArtifactRegistryRepositoryIamUpdaterProducer, ArtifactRegistryRepositoryIdParseFunc),
"google_artifact_registry_repository_iam_policy": ResourceIamPolicy(ArtifactRegistryRepositoryIamSchema, ArtifactRegistryRepositoryIamUpdaterProducer, ArtifactRegistryRepositoryIdParseFunc),
"google_beyondcorp_app_connector": resourceBeyondcorpAppConnector(),
"google_beyondcorp_app_gateway": resourceBeyondcorpAppGateway(),
"google_bigquery_dataset": resourceBigQueryDataset(),
"google_bigquery_dataset_access": resourceBigQueryDatasetAccess(),
"google_bigquery_job": resourceBigQueryJob(),
Expand Down Expand Up @@ -1541,6 +1551,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.ApigeeBasePath = d.Get("apigee_custom_endpoint").(string)
config.AppEngineBasePath = d.Get("app_engine_custom_endpoint").(string)
config.ArtifactRegistryBasePath = d.Get("artifact_registry_custom_endpoint").(string)
config.BeyondcorpBasePath = d.Get("beyondcorp_custom_endpoint").(string)
config.BigQueryBasePath = d.Get("big_query_custom_endpoint").(string)
config.BigqueryAnalyticsHubBasePath = d.Get("bigquery_analytics_hub_custom_endpoint").(string)
config.BigqueryConnectionBasePath = d.Get("bigquery_connection_custom_endpoint").(string)
Expand Down

0 comments on commit 6771e71

Please sign in to comment.