Skip to content

Commit

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

* 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
  • Loading branch information
f1urps authored and nevzheng committed Sep 22, 2023
1 parent d284131 commit 57d66ee
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 0 deletions.
97 changes: 97 additions & 0 deletions mmv1/products/edgenetwork/Network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright 2023 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Resource
name: 'Network'
description: |
A Distributed Cloud Edge network, which provides L3 isolation within a zone.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/network/rest/v1/projects.locations.zones.networks'
guides:
'Create and manage networks': 'https://cloud.google.com/distributed-cloud/edge/latest/docs/networks#api'
base_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks'
self_link: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}'
create_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks?networkId={{network_id}}'
immutable: true
autogen_async: true
timeouts: !ruby/object:Api::Timeouts
delete_minutes: 30
import_format: ['projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}', '{{name}}']
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'edgenetwork_network'
primary_resource_id: 'example_network'
skip_test: true
vars:
edgenetwork_network_id: 'example-network'
test_env_vars:
location: :REGION
zone: :ZONE
parameters:
- !ruby/object:Api::Type::String
name: 'location'
required: true
immutable: true
url_param_only: true
description: |
The Google Cloud region to which the target Distributed Cloud Edge zone belongs.
- !ruby/object:Api::Type::String
name: 'zone'
required: true
immutable: true
url_param_only: true
description: |
The name of the target Distributed Cloud Edge zone.
- !ruby/object:Api::Type::String
name: 'network_id'
required: true
immutable: true
url_param_only: true
description: |
A unique ID that identifies this network.
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
The canonical name of this resource, with format
`projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}`
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
required: false
description: |
Labels associated with this resource.
- !ruby/object:Api::Type::String
name: 'description'
required: false
description: |
A free-text description of the resource. Max length 1024 characters.
- !ruby/object:Api::Type::String
name: 'createTime'
output: true
description: |
The time when the subnet was created.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`.
- !ruby/object:Api::Type::String
name: 'updateTime'
output: true
description: |
The time when the subnet was last updated.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`.
- !ruby/object:Api::Type::Integer
name: 'mtu'
default_value: 1500
description: |
IP (L3) MTU value of the network. Default value is `1500`. Possible values are: `1500`, `9000`.
138 changes: 138 additions & 0 deletions mmv1/products/edgenetwork/Subnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Copyright 2023 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Resource
name: 'Subnet'
description: |
A Distributed Cloud Edge subnet, which provides L2 isolation within a network.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/network/rest/v1/projects.locations.zones.subnets'
guides:
'Create and manage subnetworks': 'https://cloud.google.com/distributed-cloud/edge/latest/docs/subnetworks#api'
base_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets'
self_link: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}'
create_url: 'projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets?subnetId={{subnet_id}}'
immutable: true
autogen_async: true
timeouts: !ruby/object:Api::Timeouts
delete_minutes: 30
import_format: ['projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}', '{{name}}']
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'edgenetwork_subnet'
primary_resource_id: 'example_subnet'
skip_test: true
vars:
edgenetwork_subnet_id: 'example-subnet'
edgenetwork_network_id: 'example-network'
test_env_vars:
location: :REGION
zone: :ZONE
- !ruby/object:Provider::Terraform::Examples
name: 'edgenetwork_subnet_with_vlan_id'
primary_resource_id: 'example_subnet_with_vlan_id'
skip_test: true
vars:
edgenetwork_subnet_id: 'example-subnet-with-vlan-id'
edgenetwork_network_id: 'example-network'
test_env_vars:
location: :REGION
zone: :ZONE
parameters:
- !ruby/object:Api::Type::String
name: 'location'
required: true
immutable: true
url_param_only: true
description: |
The Google Cloud region to which the target Distributed Cloud Edge zone belongs.
- !ruby/object:Api::Type::String
name: 'zone'
required: true
immutable: true
url_param_only: true
description: |
The name of the target Distributed Cloud Edge zone.
- !ruby/object:Api::Type::String
name: 'subnet_id'
required: true
immutable: true
url_param_only: true
description: |
A unique ID that identifies this subnet.
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
The canonical name of this resource, with format
`projects/{{project}}/locations/{{location}}/zones/{{zone}}/subnets/{{subnet_id}}`
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
required: false
description: |
Labels associated with this resource.
- !ruby/object:Api::Type::String
name: 'description'
required: false
description: |
A free-text description of the resource. Max length 1024 characters.
- !ruby/object:Api::Type::String
name: 'createTime'
output: true
description: |
The time when the subnet was created.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`.
- !ruby/object:Api::Type::String
name: 'updateTime'
output: true
description: |
The time when the subnet was last updated.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine
fractional digits. Examples: `2014-10-02T15:01:23Z` and `2014-10-02T15:01:23.045123456Z`.
- !ruby/object:Api::Type::ResourceRef
name: 'network'
resource: 'Network'
imports: 'name'
required: true
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.erb'
description: |
The ID of the network to which this router belongs.
Must be of the form: `projects/{{project}}/locations/{{location}}/zones/{{zone}}/networks/{{network_id}}`
- !ruby/object:Api::Type::Array
name: 'ipv4Cidr'
item_type: Api::Type::String
description: |
The ranges of ipv4 addresses that are owned by this subnetwork, in CIDR format.
- !ruby/object:Api::Type::Array
name: 'ipv6Cidr'
item_type: Api::Type::String
description: |
The ranges of ipv6 addresses that are owned by this subnetwork, in CIDR format.
- !ruby/object:Api::Type::Integer
name: 'vlanId'
default_from_api: true
description: |
VLAN ID for this subnetwork. If not specified, one is assigned automatically.
- !ruby/object:Api::Type::Enum
name: 'state'
output: true
values:
- :STATE_PENDING
- :STATE_PROVISIONING
- :STATE_RUNNING
- :STATE_SUSPENDED
- :STATE_DELETING
description: |
Current stage of the resource to the device by config push.
42 changes: 42 additions & 0 deletions mmv1/products/edgenetwork/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Product
name: Edgenetwork
display_name: Distributed Cloud Edge Network
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://edgenetwork.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Distributed Cloud Edge Network API
url: https://console.cloud.google.com/apis/library/edgenetwork.googleapis.com
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
2 changes: 2 additions & 0 deletions mmv1/templates/terraform/env_var_context.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
"<%= var_name -%>": envvar.GetTestIdentityUserFromEnv(t),
<% elsif var_type == :PAP_DESCRIPTION -%>
"<%= var_name -%>": envvar.GetTestPublicAdvertisedPrefixDescriptionFromEnv(t),
<% elsif var_type == :ZONE -%>
"<%= var_name -%>": envvar.GetTestZoneFromEnv(),
<% end -%>
<% end -%>
12 changes: 12 additions & 0 deletions mmv1/templates/terraform/examples/edgenetwork_network.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_edgenetwork_network" "<%= ctx[:primary_resource_id] %>" {
network_id = "<%= ctx[:vars]['edgenetwork_network_id'] %>"
location = "<%= ctx[:test_env_vars]['location'] %>"
zone = "<%= ctx[:test_env_vars]['zone'] %>"
description = "Example network."
mtu = 9000
labels = {
"environment" : "dev"
}
}


20 changes: 20 additions & 0 deletions mmv1/templates/terraform/examples/edgenetwork_subnet.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

resource "google_edgenetwork_subnet" "<%= ctx[:primary_resource_id] %>" {
subnet_id = "<%= ctx[:vars]['edgenetwork_subnet_id'] %>"
location = "<%= ctx[:test_env_vars]['location'] %>"
zone = "<%= ctx[:test_env_vars]['zone'] %>"
description = "Example subnet."
network = google_edgenetwork_network.example_network.id
ipv4_cidr = ["4.4.4.1/24"]
labels = {
"environment" : "dev"
}
}

resource "google_edgenetwork_network" "example_network" {
network_id = "<%= ctx[:vars]['edgenetwork_network_id'] %>"
location = "<%= ctx[:test_env_vars]['location'] %>"
zone = "<%= ctx[:test_env_vars]['zone'] %>"
description = "Example network."
mtu = 9000
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

resource "google_edgenetwork_subnet" "<%= ctx[:primary_resource_id] %>" {
subnet_id = "<%= ctx[:vars]['edgenetwork_subnet_id'] %>"
location = "<%= ctx[:test_env_vars]['location'] %>"
zone = "<%= ctx[:test_env_vars]['zone'] %>"
description = "Example subnet with VLAN ID."
network = google_edgenetwork_network.example_network.id
ipv6_cidr = ["4444:4444:4444:4444::1/64"]
vlan_id = 44
labels = {
"environment" : "dev"
}
}

resource "google_edgenetwork_network" "example_network" {
network_id = "<%= ctx[:vars]['edgenetwork_network_id'] %>"
location = "<%= ctx[:test_env_vars]['location'] %>"
zone = "<%= ctx[:test_env_vars]['zone'] %>"
description = "Example network."
mtu = 9000
}

0 comments on commit 57d66ee

Please sign in to comment.