Skip to content

Commit

Permalink
Add Network and Subnet resources for edgenetwork (#8905) (#6305)
Browse files Browse the repository at this point in the history
* Add Network and Subnet resources for edgenetwork

* Fix lint

* Added labels field to acceptance tests; Removed send_empty_value:false from vlan_id field in Subnet

* Skip edgenetwork acceptance tests

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 18, 2023
1 parent e79b771 commit f833445
Show file tree
Hide file tree
Showing 15 changed files with 1,645 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changelog/8905.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:new-resource
edgenetwork : `google_edgenetwork_network`
```
```release-note:new-resource
edgenetwork : `google_edgenetwork_subnet`
```
5 changes: 5 additions & 0 deletions .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ var services = mapOf(
"displayName" to "Documentaiwarehouse",
"path" to "./google-beta/services/documentaiwarehouse"
),
"edgenetwork" to mapOf(
"name" to "edgenetwork",
"displayName" to "Edgenetwork",
"path" to "./google-beta/services/edgenetwork"
),
"essentialcontacts" to mapOf(
"name" to "essentialcontacts",
"displayName" to "Essentialcontacts",
Expand Down
1 change: 1 addition & 0 deletions google-beta/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type ProviderModel struct {
DNSCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"`
DocumentAICustomEndpoint types.String `tfsdk:"document_ai_custom_endpoint"`
DocumentAIWarehouseCustomEndpoint types.String `tfsdk:"document_ai_warehouse_custom_endpoint"`
EdgenetworkCustomEndpoint types.String `tfsdk:"edgenetwork_custom_endpoint"`
EssentialContactsCustomEndpoint types.String `tfsdk:"essential_contacts_custom_endpoint"`
FilestoreCustomEndpoint types.String `tfsdk:"filestore_custom_endpoint"`
FirebaseCustomEndpoint types.String `tfsdk:"firebase_custom_endpoint"`
Expand Down
6 changes: 6 additions & 0 deletions google-beta/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"edgenetwork_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"essential_contacts_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
10 changes: 10 additions & 0 deletions google-beta/fwtransport/framework_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type FrameworkProviderConfig struct {
DNSBasePath string
DocumentAIBasePath string
DocumentAIWarehouseBasePath string
EdgenetworkBasePath string
EssentialContactsBasePath string
FilestoreBasePath string
FirebaseBasePath string
Expand Down Expand Up @@ -264,6 +265,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
p.DNSBasePath = data.DNSCustomEndpoint.ValueString()
p.DocumentAIBasePath = data.DocumentAICustomEndpoint.ValueString()
p.DocumentAIWarehouseBasePath = data.DocumentAIWarehouseCustomEndpoint.ValueString()
p.EdgenetworkBasePath = data.EdgenetworkCustomEndpoint.ValueString()
p.EssentialContactsBasePath = data.EssentialContactsCustomEndpoint.ValueString()
p.FilestoreBasePath = data.FilestoreCustomEndpoint.ValueString()
p.FirebaseBasePath = data.FirebaseCustomEndpoint.ValueString()
Expand Down Expand Up @@ -952,6 +954,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
data.DocumentAIWarehouseCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.EdgenetworkCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_EDGENETWORK_CUSTOM_ENDPOINT",
}, transport_tpg.DefaultBasePaths[transport_tpg.EdgenetworkBasePathKey])
if customEndpoint != nil {
data.EdgenetworkCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.EssentialContactsCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_ESSENTIAL_CONTACTS_CUSTOM_ENDPOINT",
Expand Down
13 changes: 11 additions & 2 deletions google-beta/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/dns"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/documentai"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/documentaiwarehouse"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/edgenetwork"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/essentialcontacts"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/filestore"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebase"
Expand Down Expand Up @@ -511,6 +512,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"edgenetwork_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"essential_contacts_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1115,9 +1121,9 @@ func DatasourceMapWithErrors() (map[string]*schema.Resource, error) {
})
}

// Generated resources: 386
// Generated resources: 388
// Generated IAM resources: 240
// Total generated resources: 626
// Total generated resources: 628
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -1481,6 +1487,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_document_ai_processor_default_version": documentai.ResourceDocumentAIProcessorDefaultVersion(),
"google_document_ai_warehouse_document_schema": documentaiwarehouse.ResourceDocumentAIWarehouseDocumentSchema(),
"google_document_ai_warehouse_location": documentaiwarehouse.ResourceDocumentAIWarehouseLocation(),
"google_edgenetwork_network": edgenetwork.ResourceEdgenetworkNetwork(),
"google_edgenetwork_subnet": edgenetwork.ResourceEdgenetworkSubnet(),
"google_essential_contacts_contact": essentialcontacts.ResourceEssentialContactsContact(),
"google_filestore_backup": filestore.ResourceFilestoreBackup(),
"google_filestore_instance": filestore.ResourceFilestoreInstance(),
Expand Down Expand Up @@ -2051,6 +2059,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.DNSBasePath = d.Get("dns_custom_endpoint").(string)
config.DocumentAIBasePath = d.Get("document_ai_custom_endpoint").(string)
config.DocumentAIWarehouseBasePath = d.Get("document_ai_warehouse_custom_endpoint").(string)
config.EdgenetworkBasePath = d.Get("edgenetwork_custom_endpoint").(string)
config.EssentialContactsBasePath = d.Get("essential_contacts_custom_endpoint").(string)
config.FilestoreBasePath = d.Get("filestore_custom_endpoint").(string)
config.FirebaseBasePath = d.Get("firebase_custom_endpoint").(string)
Expand Down
92 changes: 92 additions & 0 deletions google-beta/services/edgenetwork/edgenetwork_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** 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 edgenetwork

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

"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

type EdgenetworkOperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *EdgenetworkOperationWaiter) 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.EdgenetworkBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

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

// nolint: deadcode,unused
func EdgenetworkOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createEdgenetworkWaiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
if len(rawResponse) == 0 {
return errors.New("`resource` not set in operation response")
}
return json.Unmarshal(rawResponse, response)
}

func EdgenetworkOperationWaitTime(config *transport_tpg.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 := createEdgenetworkWaiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
}
Loading

0 comments on commit f833445

Please sign in to comment.