Skip to content

Commit

Permalink
Merge pull request #198 from inspec/CHEF-7209-MAGIC-MODULE-compute_v1…
Browse files Browse the repository at this point in the history
…-TargetInstance

CHEF-7209-MAGIC-MODULE-compute_v1-TargetInstance - Resource Implementation
  • Loading branch information
sa-progress authored Nov 28, 2024
2 parents 1f2e83e + 27a9cc4 commit 9a88014
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 2 deletions.
170 changes: 168 additions & 2 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24833,6 +24833,172 @@ objects:



- !ruby/object:Api::Resource
name: TargetInstance
base_url: 'projects/{{project}}/zones/{{zone}}/targetInstances'
self_link: 'projects/{{project}}/zones/{{zone}}/targetInstances/{{targetInstance}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/compute/docs'
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'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
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.
properties:

- !ruby/object:Api::Type::String
name: 'kind'
description: |
[Output Only] The type of the resource. Always compute#targetInstance for target instances.
- !ruby/object:Api::Type::String
name: 'id'
description: |
[Output Only] The unique identifier for the resource. This identifier is defined by the server.
- !ruby/object:Api::Type::String
name: 'creationTimestamp'
description: |
[Output Only] Creation timestamp in RFC3339 text format.
- !ruby/object:Api::Type::String
name: 'name'
description: |
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.
- !ruby/object:Api::Type::String
name: 'description'
description: |
An optional description of this resource. Provide this property when you create the resource.
- !ruby/object:Api::Type::String
name: 'zone'
description: |
[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.
- !ruby/object:Api::Type::Enum
name: 'natPolicy'
description: |
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.
values:
- :NO_NAT
- !ruby/object:Api::Type::String
name: 'instance'
description: |
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
- !ruby/object:Api::Type::String
name: 'selfLink'
description: |
[Output Only] Server-defined URL for the resource.
- !ruby/object:Api::Type::String
name: 'selfLinkWithId'
description: |
[Output Only] Server-defined URL for this resource with the resource id.
- !ruby/object:Api::Type::String
name: 'network'
description: |
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.
- !ruby/object:Api::Type::String
name: 'securityPolicy'
description: |
[Output Only] The resource URL for the security policy associated with this target instance.




- !ruby/object:Api::Resource
name: TargetInstance
base_url: 'projects/{{project}}/zones/{{zone}}/targetInstances'
self_link: 'projects/{{project}}/zones/{{zone}}/targetInstances/{{targetInstance}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/compute/docs'
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'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
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.
properties:

- !ruby/object:Api::Type::String
name: 'kind'
description: |
[Output Only] The type of the resource. Always compute#targetInstance for target instances.
- !ruby/object:Api::Type::String
name: 'id'
description: |
[Output Only] The unique identifier for the resource. This identifier is defined by the server.
- !ruby/object:Api::Type::String
name: 'creationTimestamp'
description: |
[Output Only] Creation timestamp in RFC3339 text format.
- !ruby/object:Api::Type::String
name: 'name'
description: |
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.
- !ruby/object:Api::Type::String
name: 'description'
description: |
An optional description of this resource. Provide this property when you create the resource.
- !ruby/object:Api::Type::String
name: 'zone'
description: |
[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.
- !ruby/object:Api::Type::Enum
name: 'natPolicy'
description: |
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.
values:
- :NO_NAT
- !ruby/object:Api::Type::String
name: 'instance'
description: |
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
- !ruby/object:Api::Type::String
name: 'selfLink'
description: |
[Output Only] Server-defined URL for the resource.
- !ruby/object:Api::Type::String
name: 'selfLinkWithId'
description: |
[Output Only] Server-defined URL for this resource with the resource id.
- !ruby/object:Api::Type::String
name: 'network'
description: |
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.
- !ruby/object:Api::Type::String
name: 'securityPolicy'
description: |
[Output Only] The resource URL for the security policy associated with this target instance.




- !ruby/object:Api::Resource
name: TargetVpnGateway
base_url: 'projects/{{project}}/regions/{{region}}/targetVpnGateways'
Expand Down Expand Up @@ -24861,7 +25027,7 @@ objects:
description: |-
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.
properties:

- !ruby/object:Api::Type::String
name: 'kind'
description: |
Expand Down Expand Up @@ -24921,7 +25087,7 @@ objects:
- !ruby/object:Api::Type::String
name: 'additionalProperties'
description: |

- !ruby/object:Api::Type::String
name: 'labelFingerprint'
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% target_instance = grab_attributes(pwd)['target_instance'] -%>
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
it { should exist }
its('kind') { should cmp <%= doc_generation ? "'#{target_instance['kind']}'" : "target_instance['kind']" -%> }
its('id') { should cmp <%= doc_generation ? "'#{target_instance['id']}'" : "target_instance['id']" -%> }
its('creation_timestamp') { should cmp <%= doc_generation ? "'#{target_instance['creation_timestamp']}'" : "target_instance['creation_timestamp']" -%> }
its('name') { should cmp <%= doc_generation ? "'#{target_instance['name']}'" : "target_instance['name']" -%> }
its('description') { should cmp <%= doc_generation ? "'#{target_instance['description']}'" : "target_instance['description']" -%> }
its('zone') { should cmp <%= doc_generation ? "'#{target_instance['zone']}'" : "target_instance['zone']" -%> }
its('nat_policy') { should cmp <%= doc_generation ? "'#{target_instance['nat_policy']}'" : "target_instance['nat_policy']" -%> }
its('instance') { should cmp <%= doc_generation ? "'#{target_instance['instance']}'" : "target_instance['instance']" -%> }
its('self_link') { should cmp <%= doc_generation ? "'#{target_instance['self_link']}'" : "target_instance['self_link']" -%> }
its('self_link_with_id') { should cmp <%= doc_generation ? "'#{target_instance['self_link_with_id']}'" : "target_instance['self_link_with_id']" -%> }
its('network') { should cmp <%= doc_generation ? "'#{target_instance['network']}'" : "target_instance['network']" -%> }
its('security_policy') { should cmp <%= doc_generation ? "'#{target_instance['security_policy']}'" : "target_instance['security_policy']" -%> }

end

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
it { should_not exist }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gcp_project_id = input(:gcp_project_id, value: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.')

target_instance = input('target_instance', value: <%= JSON.pretty_generate(grab_attributes(pwd)['target_instance']) -%>, description: 'target_instance description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% target_instance = grab_attributes(pwd)['target_instance'] -%>
describe google_compute_target_instances(project: <%= gcp_project_id -%>, zone: <%= doc_generation ? "' #{target_instance['zone']}'":"target_instance['zone']" -%>) do
it { should exist }
end
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,22 @@ region_disk_type:
zone : "value_zone"
self_link : "value_selflink"
default_disk_size_gb : "value_defaultdisksizegb"
target_instance:
project : "value_project"
region : "value_region"
url_map : "value_urlmap"
kind : "value_kind"
id : "value_id"
creation_timestamp : "value_creationtimestamp"
name : "value_name"
description : "value_description"
zone : "value_zone"
nat_policy : "value_natpolicy"
instance : "value_instance"
self_link : "value_selflink"
self_link_with_id : "value_selflinkwithid"
network : "value_network"
security_policy : "value_securitypolicy"
target_vpn_gateway:
project : "value_project"
region : "value_region"
Expand Down

0 comments on commit 9a88014

Please sign in to comment.