Skip to content

Commit 9a88014

Browse files
authored
Merge pull request #198 from inspec/CHEF-7209-MAGIC-MODULE-compute_v1-TargetInstance
CHEF-7209-MAGIC-MODULE-compute_v1-TargetInstance - Resource Implementation
2 parents 1f2e83e + 27a9cc4 commit 9a88014

5 files changed

Lines changed: 214 additions & 2 deletions

File tree

mmv1/products/compute/api.yaml

Lines changed: 168 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24833,6 +24833,172 @@ objects:
2483324833

2483424834

2483524835

24836+
- !ruby/object:Api::Resource
24837+
name: TargetInstance
24838+
base_url: 'projects/{{project}}/zones/{{zone}}/targetInstances'
24839+
self_link: 'projects/{{project}}/zones/{{zone}}/targetInstances/{{targetInstance}}'
24840+
references: !ruby/object:Api::Resource::ReferenceLinks
24841+
guides:
24842+
'Official Documentation':
24843+
api: 'https://cloud.google.com/compute/docs'
24844+
async: !ruby/object:Api::OpAsync
24845+
operation: !ruby/object:Api::OpAsync::Operation
24846+
path: 'name'
24847+
base_url: '{op_id}'
24848+
wait_ms: 1000
24849+
result: !ruby/object:Api::OpAsync::Result
24850+
path: 'response'
24851+
resource_inside_response: true
24852+
status: !ruby/object:Api::OpAsync::Status
24853+
path: 'done'
24854+
complete: True
24855+
allowed:
24856+
- True
24857+
- False
24858+
error: !ruby/object:Api::OpAsync::Error
24859+
path: 'error'
24860+
message: 'message'
24861+
description: |-
24862+
Represents a Target Instance resource. You can use a target instance to handle traffic for one or more forwarding rules, which is ideal for forwarding protocol traffic that is managed by a single source. For example, ESP, AH, TCP, or UDP. For more information, read Target instances.
24863+
properties:
24864+
24865+
- !ruby/object:Api::Type::String
24866+
name: 'kind'
24867+
description: |
24868+
[Output Only] The type of the resource. Always compute#targetInstance for target instances.
24869+
- !ruby/object:Api::Type::String
24870+
name: 'id'
24871+
description: |
24872+
[Output Only] The unique identifier for the resource. This identifier is defined by the server.
24873+
- !ruby/object:Api::Type::String
24874+
name: 'creationTimestamp'
24875+
description: |
24876+
[Output Only] Creation timestamp in RFC3339 text format.
24877+
- !ruby/object:Api::Type::String
24878+
name: 'name'
24879+
description: |
24880+
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
24881+
- !ruby/object:Api::Type::String
24882+
name: 'description'
24883+
description: |
24884+
An optional description of this resource. Provide this property when you create the resource.
24885+
- !ruby/object:Api::Type::String
24886+
name: 'zone'
24887+
description: |
24888+
[Output Only] URL of the zone where the target instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.
24889+
- !ruby/object:Api::Type::Enum
24890+
name: 'natPolicy'
24891+
description: |
24892+
Must have a value of NO_NAT. Protocol forwarding delivers packets while preserving the destination IP address of the forwarding rule referencing the target instance.
24893+
values:
24894+
- :NO_NAT
24895+
- !ruby/object:Api::Type::String
24896+
name: 'instance'
24897+
description: |
24898+
A URL to the virtual machine instance that handles traffic for this target instance. When creating a target instance, you can provide the fully-qualified URL or a valid partial URL to the desired virtual machine. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance - zones/zone/instances/instance
24899+
- !ruby/object:Api::Type::String
24900+
name: 'selfLink'
24901+
description: |
24902+
[Output Only] Server-defined URL for the resource.
24903+
- !ruby/object:Api::Type::String
24904+
name: 'selfLinkWithId'
24905+
description: |
24906+
[Output Only] Server-defined URL for this resource with the resource id.
24907+
- !ruby/object:Api::Type::String
24908+
name: 'network'
24909+
description: |
24910+
The URL of the network this target instance uses to forward traffic. If not specified, the traffic will be forwarded to the network that the default network interface belongs to.
24911+
- !ruby/object:Api::Type::String
24912+
name: 'securityPolicy'
24913+
description: |
24914+
[Output Only] The resource URL for the security policy associated with this target instance.
24915+
24916+
24917+
24918+
24919+
- !ruby/object:Api::Resource
24920+
name: TargetInstance
24921+
base_url: 'projects/{{project}}/zones/{{zone}}/targetInstances'
24922+
self_link: 'projects/{{project}}/zones/{{zone}}/targetInstances/{{targetInstance}}'
24923+
references: !ruby/object:Api::Resource::ReferenceLinks
24924+
guides:
24925+
'Official Documentation':
24926+
api: 'https://cloud.google.com/compute/docs'
24927+
async: !ruby/object:Api::OpAsync
24928+
operation: !ruby/object:Api::OpAsync::Operation
24929+
path: 'name'
24930+
base_url: '{op_id}'
24931+
wait_ms: 1000
24932+
result: !ruby/object:Api::OpAsync::Result
24933+
path: 'response'
24934+
resource_inside_response: true
24935+
status: !ruby/object:Api::OpAsync::Status
24936+
path: 'done'
24937+
complete: True
24938+
allowed:
24939+
- True
24940+
- False
24941+
error: !ruby/object:Api::OpAsync::Error
24942+
path: 'error'
24943+
message: 'message'
24944+
description: |-
24945+
Represents a Target Instance resource. You can use a target instance to handle traffic for one or more forwarding rules, which is ideal for forwarding protocol traffic that is managed by a single source. For example, ESP, AH, TCP, or UDP. For more information, read Target instances.
24946+
properties:
24947+
24948+
- !ruby/object:Api::Type::String
24949+
name: 'kind'
24950+
description: |
24951+
[Output Only] The type of the resource. Always compute#targetInstance for target instances.
24952+
- !ruby/object:Api::Type::String
24953+
name: 'id'
24954+
description: |
24955+
[Output Only] The unique identifier for the resource. This identifier is defined by the server.
24956+
- !ruby/object:Api::Type::String
24957+
name: 'creationTimestamp'
24958+
description: |
24959+
[Output Only] Creation timestamp in RFC3339 text format.
24960+
- !ruby/object:Api::Type::String
24961+
name: 'name'
24962+
description: |
24963+
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
24964+
- !ruby/object:Api::Type::String
24965+
name: 'description'
24966+
description: |
24967+
An optional description of this resource. Provide this property when you create the resource.
24968+
- !ruby/object:Api::Type::String
24969+
name: 'zone'
24970+
description: |
24971+
[Output Only] URL of the zone where the target instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.
24972+
- !ruby/object:Api::Type::Enum
24973+
name: 'natPolicy'
24974+
description: |
24975+
Must have a value of NO_NAT. Protocol forwarding delivers packets while preserving the destination IP address of the forwarding rule referencing the target instance.
24976+
values:
24977+
- :NO_NAT
24978+
- !ruby/object:Api::Type::String
24979+
name: 'instance'
24980+
description: |
24981+
A URL to the virtual machine instance that handles traffic for this target instance. When creating a target instance, you can provide the fully-qualified URL or a valid partial URL to the desired virtual machine. For example, the following are all valid URLs: - https://www.googleapis.com/compute/v1/projects/project/zones/zone /instances/instance - projects/project/zones/zone/instances/instance - zones/zone/instances/instance
24982+
- !ruby/object:Api::Type::String
24983+
name: 'selfLink'
24984+
description: |
24985+
[Output Only] Server-defined URL for the resource.
24986+
- !ruby/object:Api::Type::String
24987+
name: 'selfLinkWithId'
24988+
description: |
24989+
[Output Only] Server-defined URL for this resource with the resource id.
24990+
- !ruby/object:Api::Type::String
24991+
name: 'network'
24992+
description: |
24993+
The URL of the network this target instance uses to forward traffic. If not specified, the traffic will be forwarded to the network that the default network interface belongs to.
24994+
- !ruby/object:Api::Type::String
24995+
name: 'securityPolicy'
24996+
description: |
24997+
[Output Only] The resource URL for the security policy associated with this target instance.
24998+
24999+
25000+
25001+
2483625002
- !ruby/object:Api::Resource
2483725003
name: TargetVpnGateway
2483825004
base_url: 'projects/{{project}}/regions/{{region}}/targetVpnGateways'
@@ -24861,7 +25027,7 @@ objects:
2486125027
description: |-
2486225028
Represents a Target VPN Gateway resource. The target VPN gateway resource represents a Classic Cloud VPN gateway. For more information, read the the Cloud VPN Overview.
2486325029
properties:
24864-
25030+
2486525031
- !ruby/object:Api::Type::String
2486625032
name: 'kind'
2486725033
description: |
@@ -24921,7 +25087,7 @@ objects:
2492125087
- !ruby/object:Api::Type::String
2492225088
name: 'additionalProperties'
2492325089
description: |
24924-
25090+
2492525091
- !ruby/object:Api::Type::String
2492625092
name: 'labelFingerprint'
2492725093
description: |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
2+
<% target_instance = grab_attributes(pwd)['target_instance'] -%>
3+
describe google_compute_target_instance(project: <%= gcp_project_id -%>, targetInstance: <%= doc_generation ? "' #{target_instance['targetInstance']}'":"target_instance['targetInstance']" -%>, zone: <%= doc_generation ? "' #{target_instance['zone']}'":"target_instance['zone']" -%>) do
4+
it { should exist }
5+
its('kind') { should cmp <%= doc_generation ? "'#{target_instance['kind']}'" : "target_instance['kind']" -%> }
6+
its('id') { should cmp <%= doc_generation ? "'#{target_instance['id']}'" : "target_instance['id']" -%> }
7+
its('creation_timestamp') { should cmp <%= doc_generation ? "'#{target_instance['creation_timestamp']}'" : "target_instance['creation_timestamp']" -%> }
8+
its('name') { should cmp <%= doc_generation ? "'#{target_instance['name']}'" : "target_instance['name']" -%> }
9+
its('description') { should cmp <%= doc_generation ? "'#{target_instance['description']}'" : "target_instance['description']" -%> }
10+
its('zone') { should cmp <%= doc_generation ? "'#{target_instance['zone']}'" : "target_instance['zone']" -%> }
11+
its('nat_policy') { should cmp <%= doc_generation ? "'#{target_instance['nat_policy']}'" : "target_instance['nat_policy']" -%> }
12+
its('instance') { should cmp <%= doc_generation ? "'#{target_instance['instance']}'" : "target_instance['instance']" -%> }
13+
its('self_link') { should cmp <%= doc_generation ? "'#{target_instance['self_link']}'" : "target_instance['self_link']" -%> }
14+
its('self_link_with_id') { should cmp <%= doc_generation ? "'#{target_instance['self_link_with_id']}'" : "target_instance['self_link_with_id']" -%> }
15+
its('network') { should cmp <%= doc_generation ? "'#{target_instance['network']}'" : "target_instance['network']" -%> }
16+
its('security_policy') { should cmp <%= doc_generation ? "'#{target_instance['security_policy']}'" : "target_instance['security_policy']" -%> }
17+
18+
end
19+
20+
describe google_compute_target_instance(project: <%= gcp_project_id -%>, targetInstance: <%= doc_generation ? "' #{target_instance['targetInstance']}'":"target_instance['targetInstance']" -%>, zone: <%= doc_generation ? "' #{target_instance['zone']}'":"target_instance['zone']" -%>) do
21+
it { should_not exist }
22+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gcp_project_id = input(:gcp_project_id, value: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.')
2+
3+
target_instance = input('target_instance', value: <%= JSON.pretty_generate(grab_attributes(pwd)['target_instance']) -%>, description: 'target_instance description')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
2+
<% target_instance = grab_attributes(pwd)['target_instance'] -%>
3+
describe google_compute_target_instances(project: <%= gcp_project_id -%>, zone: <%= doc_generation ? "' #{target_instance['zone']}'":"target_instance['zone']" -%>) do
4+
it { should exist }
5+
end

mmv1/templates/inspec/tests/integration/configuration/mm-attributes.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,22 @@ region_disk_type:
11171117
zone : "value_zone"
11181118
self_link : "value_selflink"
11191119
default_disk_size_gb : "value_defaultdisksizegb"
1120+
target_instance:
1121+
project : "value_project"
1122+
region : "value_region"
1123+
url_map : "value_urlmap"
1124+
kind : "value_kind"
1125+
id : "value_id"
1126+
creation_timestamp : "value_creationtimestamp"
1127+
name : "value_name"
1128+
description : "value_description"
1129+
zone : "value_zone"
1130+
nat_policy : "value_natpolicy"
1131+
instance : "value_instance"
1132+
self_link : "value_selflink"
1133+
self_link_with_id : "value_selflinkwithid"
1134+
network : "value_network"
1135+
security_policy : "value_securitypolicy"
11201136
target_vpn_gateway:
11211137
project : "value_project"
11221138
region : "value_region"

0 commit comments

Comments
 (0)