Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHEF-12252 Automatically generated by magic modules for service: apigee_v1 and r… #650

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ The following resources are available in the InSpec GCP Profile
| [google_access_context_manager_access_level](docs/resources/google_access_context_manager_access_level.md) | [google_access_context_manager_access_levels](docs/resources/google_access_context_manager_access_levels.md) |
| [google_access_context_manager_access_policy](docs/resources/google_access_context_manager_access_policy.md) | [google_access_context_manager_access_policies](docs/resources/google_access_context_manager_access_policies.md) |
| [google_access_context_manager_service_perimeter](docs/resources/google_access_context_manager_service_perimeter.md) | [google_access_context_manager_service_perimeters](docs/resources/google_access_context_manager_service_perimeters.md) |
| [google_apigeegoogle_apigee_organization_envgroup](docs/resources/google_apigee_organization_envgroup.md) | [google_apigee_organization_envgroups](docs/resources/google_apigee_organization_envgroups.md) |
| [google_apigee_endpoint_attachment](docs/resources/google_apigee_endpoint_attachment.md) | [google_apigee_endpoint_attachments](docs/resources/google_apigee_endpoint_attachments.md) |
| [google_apigee_organization_envgroup](docs/resources/google_apigee_organization_envgroup.md) | [google_apigee_organization_envgroups](docs/resources/google_apigee_organization_envgroups.md) |
| [google_apigee_organization_envgroup_attachment](docs/resources/google_apigee_organization_envgroup_attachment.md) | [google_apigee_organization_envgroup_attachments](docs/resources/google_apigee_organization_envgroup_attachments.md) |
| [google_appengine_standard_app_version](docs/resources/google_appengine_standard_app_version.md) | [google_appengine_standard_app_versions](docs/resources/google_appengine_standard_app_versions.md) |
| [google_bigquery_dataset](docs/resources/google_bigquery_dataset.md) | [google_bigquery_datasets](docs/resources/google_bigquery_datasets.md) |
Expand Down
79 changes: 79 additions & 0 deletions docs/resources/google_apigee_endpoint_attachment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
+++

title = "google_apigee_endpoint_attachment Resource"
platform = "gcp"
draft = false
gh_repo = "inspec-gcp"


[menu.inspec]

title = "google_apigee_endpoint_attachment"
identifier = "inspec/resources/gcp/google_apigee_endpoint_attachment Resource"
parent = "inspec/resources/gcp"
+++

Use the `google_apigee_endpoint_attachment` InSpec audit resource to test the properties of a test a Google EndpointAttachment.

## Installation
{{% inspec_gcp_install %}}

## Syntax
A `google_apigee_endpoint_attachment` is used to test a Google EndpointAttachment resource

## Examples
```
describe google_apigee_endpoint_attachment(name: ' value_name') do
it { should exist }
its('host') { should cmp 'value_host' }
its('connection_state') { should cmp 'value_connectionstate' }
its('service_attachment') { should cmp 'value_serviceattachment' }
its('location') { should cmp 'value_location' }
its('name') { should cmp 'value_name' }
its('state') { should cmp 'value_state' }

end

describe google_apigee_endpoint_attachment(name: "does_not_exit") do
it { should_not exist }
end
```

## Parameters
Properties that can be accessed from the `google_apigee_endpoint_attachment` resource:

## Properties
Properties that can be accessed from the `google_apigee_endpoint_attachment` resource:


* `host`: Output only. Host that can be used in either the HTTP target endpoint directly or as the host in target server.

* `connection_state`: Output only. State of the endpoint attachment connection to the service attachment.
Possible values:
* CONNECTION_STATE_UNSPECIFIED
* UNAVAILABLE
* PENDING
* ACCEPTED
* REJECTED
* CLOSED
* FROZEN
* NEEDS_ATTENTION

* `service_attachment`: Format: projects/*/regions/*/serviceAttachments/*

* `location`: Required. Location of the endpoint attachment.

* `name`: Name of the endpoint attachment. Use the following structure in your request: `organizations/{org}/endpointAttachments/{endpoint_attachment}`

* `state`: Output only. State of the endpoint attachment. Values other than `ACTIVE` mean the resource is not ready to use.
Possible values:
* STATE_UNSPECIFIED
* CREATING
* ACTIVE
* DELETING
* UPDATING


## GCP Permissions

Ensure the [Apigee API](https://console.cloud.google.com/apis/library/apigee.googleapis.com/) is enabled for the current project.
64 changes: 64 additions & 0 deletions docs/resources/google_apigee_endpoint_attachments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
+++

title = "google_apigee_endpoint_attachments Resource"
platform = "gcp"
draft = false
gh_repo = "inspec-gcp"


[menu.inspec]

title = "google_apigee_endpoint_attachments"
identifier = "inspec/resources/gcp/google_apigee_endpoint_attachments Resource"
parent = "inspec/resources/gcp"
+++

Use the `google_apigee_endpoint_attachments` InSpec audit resource to test the properties of a test a Google EndpointAttachment.

## Installation
{{% inspec_gcp_install %}}

## Syntax
A `google_apigee_endpoint_attachments` is used to test a Google EndpointAttachment resource

## Examples
```
describe google_apigee_endpoint_attachments() do
it { should exist }
its('hosts') { should include 'value_host' }
its('connection_states') { should include 'value_connectionstate' }
its('service_attachments') { should include 'value_serviceattachment' }
its('locations') { should include 'value_location' }
its('names') { should include 'value_name' }
its('states') { should include 'value_state' }
end
```

## Parameters
Properties that can be accessed from the `google_apigee_endpoint_attachments` resource:

See [google_apigee_endpoint_attachment.md](google_apigee_endpoint_attachment.md) for more detailed information
* `hosts`: an array of `google_apigee_endpoint_attachment` host
* `connection_states`: an array of `google_apigee_endpoint_attachment` connection_state
* `service_attachments`: an array of `google_apigee_endpoint_attachment` service_attachment
* `locations`: an array of `google_apigee_endpoint_attachment` location
* `names`: an array of `google_apigee_endpoint_attachment` name
* `states`: an array of `google_apigee_endpoint_attachment` state
## Properties
Properties that can be accessed from the `google_apigee_endpoint_attachments` resource:

See [google_apigee_endpoint_attachment.md](google_apigee_endpoint_attachment.md) for more detailed information
* `hosts`: an array of `google_apigee_endpoint_attachment` host
* `connection_states`: an array of `google_apigee_endpoint_attachment` connection_state
* `service_attachments`: an array of `google_apigee_endpoint_attachment` service_attachment
* `locations`: an array of `google_apigee_endpoint_attachment` location
* `names`: an array of `google_apigee_endpoint_attachment` name
* `states`: an array of `google_apigee_endpoint_attachment` state

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions

Ensure the [Apigee API](https://console.cloud.google.com/apis/library/apigee.googleapis.com/) is enabled for the current project.
65 changes: 65 additions & 0 deletions libraries/google_apigee_endpoint_attachment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'

# A provider to manage Apigee resources.
class ApigeeEndpointAttachment < GcpResourceBase
name 'google_apigee_endpoint_attachment'
desc 'EndpointAttachment'
supports platform: 'gcp'

attr_reader :params
attr_reader :host
attr_reader :connection_state
attr_reader :service_attachment
attr_reader :location
attr_reader :name
attr_reader :state

def initialize(params)
super(params.merge({ use_http_transport: true }))
@params = params
@fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get')
parse unless @fetched.nil?
end

def parse
@host = @fetched['host']
@connection_state = @fetched['connectionState']
@service_attachment = @fetched['serviceAttachment']
@location = @fetched['location']
@name = @fetched['name']
@state = @fetched['state']
end

def exists?
!@fetched.nil?
end

def to_s
"EndpointAttachment #{@params[:name]}"
end

private

def product_url(_ = nil)
'https://apigee.googleapis.com/v1/'
end

def resource_base_url
'{{name}}'
end
end
89 changes: 89 additions & 0 deletions libraries/google_apigee_endpoint_attachments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
class ApigeeEndpointAttachments < GcpResourceBase
name 'google_apigee_endpoint_attachments'
desc 'EndpointAttachment plural resource'
supports platform: 'gcp'

attr_reader :table

filter_table_config = FilterTable.create

filter_table_config.add(:hosts, field: :host)
filter_table_config.add(:connection_states, field: :connection_state)
filter_table_config.add(:service_attachments, field: :service_attachment)
filter_table_config.add(:locations, field: :location)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:states, field: :state)

filter_table_config.connect(self, :table)

def initialize(params = {})
super(params.merge({ use_http_transport: true }))
@params = params
@table = fetch_wrapped_resource('endpointAttachments')
end

def fetch_wrapped_resource(wrap_path)
# fetch_resource returns an array of responses (to handle pagination)
result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get')
return if result.nil?

# Conversion of string -> object hash to symbol -> object hash that InSpec needs
converted = []
result.each do |response|
next if response.nil? || !response.key?(wrap_path)
response[wrap_path].each do |hash|
hash_with_symbols = {}
hash.each_key do |key|
name, value = transform(key, hash)
hash_with_symbols[name] = value
end
converted.push(hash_with_symbols)
end
end

converted
end

def transform(key, value)
return transformers[key].call(value) if transformers.key?(key)

[key.to_sym, value]
end

def transformers
{
'host' => ->(obj) { [:host, obj['host']] },
'connectionState' => ->(obj) { [:connection_state, obj['connectionState']] },
'serviceAttachment' => ->(obj) { [:service_attachment, obj['serviceAttachment']] },
'location' => ->(obj) { [:location, obj['location']] },
'name' => ->(obj) { [:name, obj['name']] },
'state' => ->(obj) { [:state, obj['state']] },
}
end

private

def product_url(_ = nil)
'https://apigee.googleapis.com/v1/'
end

def resource_base_url
'{{parent}}/endpointAttachments'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ----------------------------------------------------------------------------
#
# *** 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------

title 'Test GCP google_apigee_endpoint_attachment resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

endpoint_attachment = input('endpoint_attachment', value: {
"name": "organizations/ppradhan/endpointAttachments/inspec-test-attachment",
"parent": "organizations/ppradhan",
"host": "7.0.0.2",
"connection_state": "ACCEPTED",
"service_attachment": "projects/ppradhan/regions/us-central1/serviceAttachments/my-psc-ilb",
"location": "us-central1",
"state": "ACTIVE"
}, description: 'endpoint_attachment description')
control 'google_apigee_endpoint_attachment-1.0' do
impact 1.0
title 'google_apigee_endpoint_attachment resource test'

describe google_apigee_endpoint_attachment(name: endpoint_attachment['name']) do
it { should exist }
its('host') { should cmp endpoint_attachment['host'] }
its('connection_state') { should cmp endpoint_attachment['connection_state'] }
its('service_attachment') { should cmp endpoint_attachment['service_attachment'] }
its('location') { should cmp endpoint_attachment['location'] }
its('name') { should cmp endpoint_attachment['name'] }
its('state') { should cmp endpoint_attachment['state'] }

end

describe google_apigee_endpoint_attachment(name: "does_not_exit") do
it { should_not exist }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ----------------------------------------------------------------------------
#
# *** 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 README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------

title 'Test GCP google_apigee_endpoint_attachments resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

endpoint_attachment = input('endpoint_attachment', value: {
"name": "organizations/ppradhan/endpointAttachments/inspec-test-attachment",
"parent": "organizations/ppradhan",
"host": "7.0.0.2",
"connection_state": "ACCEPTED",
"service_attachment": "projects/ppradhan/regions/us-central1/serviceAttachments/my-psc-ilb",
"location": "us-central1",
"state": "ACTIVE"
}, description: 'endpoint_attachment description')
control 'google_apigee_endpoint_attachments-1.0' do
impact 1.0
title 'google_apigee_endpoint_attachments resource test'

describe google_apigee_endpoint_attachments() do
it { should exist }
its('hosts') { should include endpoint_attachment['host'] }
its('connection_states') { should include endpoint_attachment['connection_state'] }
its('service_attachments') { should include endpoint_attachment['service_attachment'] }
its('locations') { should include endpoint_attachment['location'] }
its('names') { should include endpoint_attachment['name'] }
its('states') { should include endpoint_attachment['state'] }
end
end