Skip to content

Commit 6e04110

Browse files
Add Network and Subnet resources for edgenetwork (#8905) (#15891)
* 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]>
1 parent 4235a31 commit 6e04110

15 files changed

+1645
-2
lines changed

.changelog/8905.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:new-resource
2+
edgenetwork : `google_edgenetwork_network`
3+
```
4+
```release-note:new-resource
5+
edgenetwork : `google_edgenetwork_subnet`
6+
```

.teamcity/components/generated/services.kt

+5
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ var services = mapOf(
311311
"displayName" to "Documentaiwarehouse",
312312
"path" to "./google/services/documentaiwarehouse"
313313
),
314+
"edgenetwork" to mapOf(
315+
"name" to "edgenetwork",
316+
"displayName" to "Edgenetwork",
317+
"path" to "./google/services/edgenetwork"
318+
),
314319
"essentialcontacts" to mapOf(
315320
"name" to "essentialcontacts",
316321
"displayName" to "Essentialcontacts",

google/fwmodels/provider_model.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type ProviderModel struct {
7575
DNSCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"`
7676
DocumentAICustomEndpoint types.String `tfsdk:"document_ai_custom_endpoint"`
7777
DocumentAIWarehouseCustomEndpoint types.String `tfsdk:"document_ai_warehouse_custom_endpoint"`
78+
EdgenetworkCustomEndpoint types.String `tfsdk:"edgenetwork_custom_endpoint"`
7879
EssentialContactsCustomEndpoint types.String `tfsdk:"essential_contacts_custom_endpoint"`
7980
FilestoreCustomEndpoint types.String `tfsdk:"filestore_custom_endpoint"`
8081
FirestoreCustomEndpoint types.String `tfsdk:"firestore_custom_endpoint"`

google/fwprovider/framework_provider.go

+6
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
419419
transport_tpg.CustomEndpointValidator(),
420420
},
421421
},
422+
"edgenetwork_custom_endpoint": &schema.StringAttribute{
423+
Optional: true,
424+
Validators: []validator.String{
425+
transport_tpg.CustomEndpointValidator(),
426+
},
427+
},
422428
"essential_contacts_custom_endpoint": &schema.StringAttribute{
423429
Optional: true,
424430
Validators: []validator.String{

google/fwtransport/framework_config.go

+10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type FrameworkProviderConfig struct {
100100
DNSBasePath string
101101
DocumentAIBasePath string
102102
DocumentAIWarehouseBasePath string
103+
EdgenetworkBasePath string
103104
EssentialContactsBasePath string
104105
FilestoreBasePath string
105106
FirestoreBasePath string
@@ -245,6 +246,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
245246
p.DNSBasePath = data.DNSCustomEndpoint.ValueString()
246247
p.DocumentAIBasePath = data.DocumentAICustomEndpoint.ValueString()
247248
p.DocumentAIWarehouseBasePath = data.DocumentAIWarehouseCustomEndpoint.ValueString()
249+
p.EdgenetworkBasePath = data.EdgenetworkCustomEndpoint.ValueString()
248250
p.EssentialContactsBasePath = data.EssentialContactsCustomEndpoint.ValueString()
249251
p.FilestoreBasePath = data.FilestoreCustomEndpoint.ValueString()
250252
p.FirestoreBasePath = data.FirestoreCustomEndpoint.ValueString()
@@ -896,6 +898,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
896898
data.DocumentAIWarehouseCustomEndpoint = types.StringValue(customEndpoint.(string))
897899
}
898900
}
901+
if data.EdgenetworkCustomEndpoint.IsNull() {
902+
customEndpoint := transport_tpg.MultiEnvDefault([]string{
903+
"GOOGLE_EDGENETWORK_CUSTOM_ENDPOINT",
904+
}, transport_tpg.DefaultBasePaths[transport_tpg.EdgenetworkBasePathKey])
905+
if customEndpoint != nil {
906+
data.EdgenetworkCustomEndpoint = types.StringValue(customEndpoint.(string))
907+
}
908+
}
899909
if data.EssentialContactsCustomEndpoint.IsNull() {
900910
customEndpoint := transport_tpg.MultiEnvDefault([]string{
901911
"GOOGLE_ESSENTIAL_CONTACTS_CUSTOM_ENDPOINT",

google/provider/provider.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import (
6363
"github.com/hashicorp/terraform-provider-google/google/services/dns"
6464
"github.com/hashicorp/terraform-provider-google/google/services/documentai"
6565
"github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse"
66+
"github.com/hashicorp/terraform-provider-google/google/services/edgenetwork"
6667
"github.com/hashicorp/terraform-provider-google/google/services/essentialcontacts"
6768
"github.com/hashicorp/terraform-provider-google/google/services/filestore"
6869
"github.com/hashicorp/terraform-provider-google/google/services/firestore"
@@ -479,6 +480,11 @@ func Provider() *schema.Provider {
479480
Optional: true,
480481
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
481482
},
483+
"edgenetwork_custom_endpoint": {
484+
Type: schema.TypeString,
485+
Optional: true,
486+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
487+
},
482488
"essential_contacts_custom_endpoint": {
483489
Type: schema.TypeString,
484490
Optional: true,
@@ -987,9 +993,9 @@ func DatasourceMapWithErrors() (map[string]*schema.Resource, error) {
987993
})
988994
}
989995

990-
// Generated resources: 323
996+
// Generated resources: 325
991997
// Generated IAM resources: 210
992-
// Total generated resources: 533
998+
// Total generated resources: 535
993999
func ResourceMap() map[string]*schema.Resource {
9941000
resourceMap, _ := ResourceMapWithErrors()
9951001
return resourceMap
@@ -1311,6 +1317,8 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
13111317
"google_document_ai_processor_default_version": documentai.ResourceDocumentAIProcessorDefaultVersion(),
13121318
"google_document_ai_warehouse_document_schema": documentaiwarehouse.ResourceDocumentAIWarehouseDocumentSchema(),
13131319
"google_document_ai_warehouse_location": documentaiwarehouse.ResourceDocumentAIWarehouseLocation(),
1320+
"google_edgenetwork_network": edgenetwork.ResourceEdgenetworkNetwork(),
1321+
"google_edgenetwork_subnet": edgenetwork.ResourceEdgenetworkSubnet(),
13141322
"google_essential_contacts_contact": essentialcontacts.ResourceEssentialContactsContact(),
13151323
"google_filestore_backup": filestore.ResourceFilestoreBackup(),
13161324
"google_filestore_instance": filestore.ResourceFilestoreInstance(),
@@ -1807,6 +1815,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
18071815
config.DNSBasePath = d.Get("dns_custom_endpoint").(string)
18081816
config.DocumentAIBasePath = d.Get("document_ai_custom_endpoint").(string)
18091817
config.DocumentAIWarehouseBasePath = d.Get("document_ai_warehouse_custom_endpoint").(string)
1818+
config.EdgenetworkBasePath = d.Get("edgenetwork_custom_endpoint").(string)
18101819
config.EssentialContactsBasePath = d.Get("essential_contacts_custom_endpoint").(string)
18111820
config.FilestoreBasePath = d.Get("filestore_custom_endpoint").(string)
18121821
config.FirestoreBasePath = d.Get("firestore_custom_endpoint").(string)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package edgenetwork
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
28+
)
29+
30+
type EdgenetworkOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *EdgenetworkOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.EdgenetworkBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createEdgenetworkWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*EdgenetworkOperationWaiter, error) {
54+
w := &EdgenetworkOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func EdgenetworkOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createEdgenetworkWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func EdgenetworkOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createEdgenetworkWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)