From 1db2752a2da317a0149032bafc7123f07fddbfdf Mon Sep 17 00:00:00 2001 From: Samir <85890442+sa-progress@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:28:25 +0530 Subject: [PATCH 1/4] Automatically generated by magic modules for service: apigee_v1 and resource: Organizations__endpointAttachment. This commit includes the following changes: - Singular Resource - Plural Resource - Documentation updates - Terraform configuration - Integration tests Signed-off-by: Samir <85890442+sa-progress@users.noreply.github.com> --- ...apigee_organization_endpoint_attachment.md | 79 ++++++++++++++++ ...pigee_organization_endpoint_attachments.md | 58 ++++++++++++ ...apigee_organization_endpoint_attachment.rb | 65 ++++++++++++++ ...pigee_organization_endpoint_attachments.rb | 89 +++++++++++++++++++ ...apigee_organization_endpoint_attachment.rb | 46 ++++++++++ ...pigee_organization_endpoint_attachments.rb | 35 ++++++++ 6 files changed, 372 insertions(+) create mode 100644 docs/resources/google_apigee_organization_endpoint_attachment.md create mode 100644 docs/resources/google_apigee_organization_endpoint_attachments.md create mode 100644 libraries/google_apigee_organization_endpoint_attachment.rb create mode 100644 libraries/google_apigee_organization_endpoint_attachments.rb create mode 100644 test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb create mode 100644 test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb diff --git a/docs/resources/google_apigee_organization_endpoint_attachment.md b/docs/resources/google_apigee_organization_endpoint_attachment.md new file mode 100644 index 00000000..d4a2ab3d --- /dev/null +++ b/docs/resources/google_apigee_organization_endpoint_attachment.md @@ -0,0 +1,79 @@ ++++ + +title = "google_apigee_organization_endpoint_attachment Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_apigee_organization_endpoint_attachment" +identifier = "inspec/resources/gcp/google_apigee_organization_endpoint_attachment Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_apigee_organization_endpoint_attachment` InSpec audit resource to test the properties of a test a Google OrganizationEndpointAttachment. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_apigee_organization_endpoint_attachment` is used to test a Google OrganizationEndpointAttachment resource + +## Examples +``` +describe google_apigee_organization_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_organization_endpoint_attachment(name: "does_not_exit") do + it { should_not exist } +end +``` + +## Parameters +Properties that can be accessed from the `google_apigee_organization_endpoint_attachment` resource: + +## Properties +Properties that can be accessed from the `google_apigee_organization_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. diff --git a/docs/resources/google_apigee_organization_endpoint_attachments.md b/docs/resources/google_apigee_organization_endpoint_attachments.md new file mode 100644 index 00000000..486bdaa7 --- /dev/null +++ b/docs/resources/google_apigee_organization_endpoint_attachments.md @@ -0,0 +1,58 @@ ++++ + +title = "google_apigee_organization_endpoint_attachments Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_apigee_organization_endpoint_attachments" +identifier = "inspec/resources/gcp/google_apigee_organization_endpoint_attachments Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_apigee_organization_endpoint_attachments` InSpec audit resource to test the properties of a test a Google OrganizationEndpointAttachment. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_apigee_organization_endpoint_attachments` is used to test a Google OrganizationEndpointAttachment resource + +## Examples +``` + describe google_apigee_organization_endpoint_attachments() do + it { should exist } + end +``` + +## Parameters +Properties that can be accessed from the `google_apigee_organization_endpoint_attachments` resource: + +See [google_apigee_organization_endpoint_attachment.md](google_apigee_organization_endpoint_attachment.md) for more detailed information +* `hosts`: an array of `google_apigee_organization_endpoint_attachment` host +* `connection_states`: an array of `google_apigee_organization_endpoint_attachment` connection_state +* `service_attachments`: an array of `google_apigee_organization_endpoint_attachment` service_attachment +* `locations`: an array of `google_apigee_organization_endpoint_attachment` location +* `names`: an array of `google_apigee_organization_endpoint_attachment` name +* `states`: an array of `google_apigee_organization_endpoint_attachment` state +## Properties +Properties that can be accessed from the `google_apigee_organization_endpoint_attachments` resource: + +See [google_apigee_organization_endpoint_attachment.md](google_apigee_organization_endpoint_attachment.md) for more detailed information +* `hosts`: an array of `google_apigee_organization_endpoint_attachment` host +* `connection_states`: an array of `google_apigee_organization_endpoint_attachment` connection_state +* `service_attachments`: an array of `google_apigee_organization_endpoint_attachment` service_attachment +* `locations`: an array of `google_apigee_organization_endpoint_attachment` location +* `names`: an array of `google_apigee_organization_endpoint_attachment` name +* `states`: an array of `google_apigee_organization_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. diff --git a/libraries/google_apigee_organization_endpoint_attachment.rb b/libraries/google_apigee_organization_endpoint_attachment.rb new file mode 100644 index 00000000..eff65a55 --- /dev/null +++ b/libraries/google_apigee_organization_endpoint_attachment.rb @@ -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 ApigeeOrganizationEndpointAttachment < GcpResourceBase + name 'google_apigee_organization_endpoint_attachment' + desc 'OrganizationEndpointAttachment' + 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 + "OrganizationEndpointAttachment #{@params[:]}" + end + + private + + def product_url(_ = nil) + 'https://apigee.googleapis.com/v1/' + end + + def resource_base_url + '{{+name}}' + end +end diff --git a/libraries/google_apigee_organization_endpoint_attachments.rb b/libraries/google_apigee_organization_endpoint_attachments.rb new file mode 100644 index 00000000..a1c72aa1 --- /dev/null +++ b/libraries/google_apigee_organization_endpoint_attachments.rb @@ -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 ApigeeOrganizationEndpointAttachments < GcpResourceBase + name 'google_apigee_organization_endpoint_attachments' + desc 'OrganizationEndpointAttachment 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('organizationEndpointAttachments') + 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 diff --git a/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb b/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb new file mode 100644 index 00000000..01bafb1b --- /dev/null +++ b/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb @@ -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_organization_endpoint_attachment resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + organization_endpoint_attachment = input('organization_endpoint_attachment', value: { + "name": "value_name", + "parent": "value_parent", + "host": "value_host", + "connection_state": "value_connectionstate", + "service_attachment": "value_serviceattachment", + "location": "value_location", + "state": "value_state" +}, description: 'organization_endpoint_attachment description') +control 'google_apigee_organization_endpoint_attachment-1.0' do + impact 1.0 + title 'google_apigee_organization_endpoint_attachment resource test' + + describe google_apigee_organization_endpoint_attachment(name: organization_endpoint_attachment['name']) do + it { should exist } + its('host') { should cmp organization_endpoint_attachment['host'] } + its('connection_state') { should cmp organization_endpoint_attachment['connection_state'] } + its('service_attachment') { should cmp organization_endpoint_attachment['service_attachment'] } + its('location') { should cmp organization_endpoint_attachment['location'] } + its('name') { should cmp organization_endpoint_attachment['name'] } + its('state') { should cmp organization_endpoint_attachment['state'] } + + end + + describe google_apigee_organization_endpoint_attachment(name: "does_not_exit") do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb b/test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb new file mode 100644 index 00000000..c8ebdc9b --- /dev/null +++ b/test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb @@ -0,0 +1,35 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_organization_endpoint_attachments resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + organization_endpoint_attachment = input('organization_endpoint_attachment', value: { + "name": "value_name", + "parent": "value_parent", + "host": "value_host", + "connection_state": "value_connectionstate", + "service_attachment": "value_serviceattachment", + "location": "value_location", + "state": "value_state" +}, description: 'organization_endpoint_attachment description') +control 'google_apigee_organization_endpoint_attachments-1.0' do + impact 1.0 + title 'google_apigee_organization_endpoint_attachments resource test' + + describe google_apigee_organization_endpoint_attachments() do + it { should exist } + end +end From 499f99a36bbfa17077b65bc24fc27d1440998858 Mon Sep 17 00:00:00 2001 From: Samir <85890442+sa-progress@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:26:01 +0530 Subject: [PATCH 2/4] Linitng fixed Signed-off-by: Samir <85890442+sa-progress@users.noreply.github.com> --- libraries/google_apigee_organization_endpoint_attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/google_apigee_organization_endpoint_attachment.rb b/libraries/google_apigee_organization_endpoint_attachment.rb index eff65a55..4b524a5a 100644 --- a/libraries/google_apigee_organization_endpoint_attachment.rb +++ b/libraries/google_apigee_organization_endpoint_attachment.rb @@ -50,7 +50,7 @@ def exists? end def to_s - "OrganizationEndpointAttachment #{@params[:]}" + "OrganizationEndpointAttachment #{@params[:name]}" end private From 81563db4b05d8d339ae0f3fa69e9a94313b1e9ae Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Thu, 29 Aug 2024 17:46:44 +0530 Subject: [PATCH 3/4] rename resource name Signed-off-by: balasubramanian-s --- ...d => google_apigee_endpoint_attachment.md} | 18 +++--- .../google_apigee_endpoint_attachments.md | 58 +++++++++++++++++++ ...pigee_organization_endpoint_attachments.md | 58 ------------------- ...b => google_apigee_endpoint_attachment.rb} | 10 ++-- ... => google_apigee_endpoint_attachments.rb} | 10 ++-- .../google_apigee_endpoint_attachment.rb | 46 +++++++++++++++ ... => google_apigee_endpoint_attachments.rb} | 12 ++-- ...apigee_organization_endpoint_attachment.rb | 46 --------------- 8 files changed, 129 insertions(+), 129 deletions(-) rename docs/resources/{google_apigee_organization_endpoint_attachment.md => google_apigee_endpoint_attachment.md} (66%) create mode 100644 docs/resources/google_apigee_endpoint_attachments.md delete mode 100644 docs/resources/google_apigee_organization_endpoint_attachments.md rename libraries/{google_apigee_organization_endpoint_attachment.rb => google_apigee_endpoint_attachment.rb} (87%) rename libraries/{google_apigee_organization_endpoint_attachments.rb => google_apigee_endpoint_attachments.rb} (90%) create mode 100644 test/integration/verify/controls/google_apigee_endpoint_attachment.rb rename test/integration/verify/controls/{google_apigee_organization_endpoint_attachments.rb => google_apigee_endpoint_attachments.rb} (69%) delete mode 100644 test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb diff --git a/docs/resources/google_apigee_organization_endpoint_attachment.md b/docs/resources/google_apigee_endpoint_attachment.md similarity index 66% rename from docs/resources/google_apigee_organization_endpoint_attachment.md rename to docs/resources/google_apigee_endpoint_attachment.md index d4a2ab3d..527be5c0 100644 --- a/docs/resources/google_apigee_organization_endpoint_attachment.md +++ b/docs/resources/google_apigee_endpoint_attachment.md @@ -1,6 +1,6 @@ +++ -title = "google_apigee_organization_endpoint_attachment Resource" +title = "google_apigee_endpoint_attachment Resource" platform = "gcp" draft = false gh_repo = "inspec-gcp" @@ -8,22 +8,22 @@ gh_repo = "inspec-gcp" [menu.inspec] -title = "google_apigee_organization_endpoint_attachment" -identifier = "inspec/resources/gcp/google_apigee_organization_endpoint_attachment Resource" +title = "google_apigee_endpoint_attachment" +identifier = "inspec/resources/gcp/google_apigee_endpoint_attachment Resource" parent = "inspec/resources/gcp" +++ -Use the `google_apigee_organization_endpoint_attachment` InSpec audit resource to test the properties of a test a Google OrganizationEndpointAttachment. +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_organization_endpoint_attachment` is used to test a Google OrganizationEndpointAttachment resource +A `google_apigee_endpoint_attachment` is used to test a Google EndpointAttachment resource ## Examples ``` -describe google_apigee_organization_endpoint_attachment(name: ' value_name') do +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' } @@ -34,16 +34,16 @@ describe google_apigee_organization_endpoint_attachment(name: ' value_name') do end -describe google_apigee_organization_endpoint_attachment(name: "does_not_exit") do +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_organization_endpoint_attachment` resource: +Properties that can be accessed from the `google_apigee_endpoint_attachment` resource: ## Properties -Properties that can be accessed from the `google_apigee_organization_endpoint_attachment` resource: +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. diff --git a/docs/resources/google_apigee_endpoint_attachments.md b/docs/resources/google_apigee_endpoint_attachments.md new file mode 100644 index 00000000..a157f393 --- /dev/null +++ b/docs/resources/google_apigee_endpoint_attachments.md @@ -0,0 +1,58 @@ ++++ + +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 } + 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. diff --git a/docs/resources/google_apigee_organization_endpoint_attachments.md b/docs/resources/google_apigee_organization_endpoint_attachments.md deleted file mode 100644 index 486bdaa7..00000000 --- a/docs/resources/google_apigee_organization_endpoint_attachments.md +++ /dev/null @@ -1,58 +0,0 @@ -+++ - -title = "google_apigee_organization_endpoint_attachments Resource" -platform = "gcp" -draft = false -gh_repo = "inspec-gcp" - - -[menu.inspec] - -title = "google_apigee_organization_endpoint_attachments" -identifier = "inspec/resources/gcp/google_apigee_organization_endpoint_attachments Resource" -parent = "inspec/resources/gcp" -+++ - -Use the `google_apigee_organization_endpoint_attachments` InSpec audit resource to test the properties of a test a Google OrganizationEndpointAttachment. - -## Installation -{{% inspec_gcp_install %}} - -## Syntax -A `google_apigee_organization_endpoint_attachments` is used to test a Google OrganizationEndpointAttachment resource - -## Examples -``` - describe google_apigee_organization_endpoint_attachments() do - it { should exist } - end -``` - -## Parameters -Properties that can be accessed from the `google_apigee_organization_endpoint_attachments` resource: - -See [google_apigee_organization_endpoint_attachment.md](google_apigee_organization_endpoint_attachment.md) for more detailed information -* `hosts`: an array of `google_apigee_organization_endpoint_attachment` host -* `connection_states`: an array of `google_apigee_organization_endpoint_attachment` connection_state -* `service_attachments`: an array of `google_apigee_organization_endpoint_attachment` service_attachment -* `locations`: an array of `google_apigee_organization_endpoint_attachment` location -* `names`: an array of `google_apigee_organization_endpoint_attachment` name -* `states`: an array of `google_apigee_organization_endpoint_attachment` state -## Properties -Properties that can be accessed from the `google_apigee_organization_endpoint_attachments` resource: - -See [google_apigee_organization_endpoint_attachment.md](google_apigee_organization_endpoint_attachment.md) for more detailed information -* `hosts`: an array of `google_apigee_organization_endpoint_attachment` host -* `connection_states`: an array of `google_apigee_organization_endpoint_attachment` connection_state -* `service_attachments`: an array of `google_apigee_organization_endpoint_attachment` service_attachment -* `locations`: an array of `google_apigee_organization_endpoint_attachment` location -* `names`: an array of `google_apigee_organization_endpoint_attachment` name -* `states`: an array of `google_apigee_organization_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. diff --git a/libraries/google_apigee_organization_endpoint_attachment.rb b/libraries/google_apigee_endpoint_attachment.rb similarity index 87% rename from libraries/google_apigee_organization_endpoint_attachment.rb rename to libraries/google_apigee_endpoint_attachment.rb index 4b524a5a..715dba80 100644 --- a/libraries/google_apigee_organization_endpoint_attachment.rb +++ b/libraries/google_apigee_endpoint_attachment.rb @@ -16,9 +16,9 @@ require 'gcp_backend' # A provider to manage Apigee resources. -class ApigeeOrganizationEndpointAttachment < GcpResourceBase - name 'google_apigee_organization_endpoint_attachment' - desc 'OrganizationEndpointAttachment' +class ApigeeEndpointAttachment < GcpResourceBase + name 'google_apigee_endpoint_attachment' + desc 'EndpointAttachment' supports platform: 'gcp' attr_reader :params @@ -50,7 +50,7 @@ def exists? end def to_s - "OrganizationEndpointAttachment #{@params[:name]}" + "EndpointAttachment #{@params[:name]}" end private @@ -60,6 +60,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+name}}' + '{{name}}' end end diff --git a/libraries/google_apigee_organization_endpoint_attachments.rb b/libraries/google_apigee_endpoint_attachments.rb similarity index 90% rename from libraries/google_apigee_organization_endpoint_attachments.rb rename to libraries/google_apigee_endpoint_attachments.rb index a1c72aa1..6ab7a110 100644 --- a/libraries/google_apigee_organization_endpoint_attachments.rb +++ b/libraries/google_apigee_endpoint_attachments.rb @@ -14,9 +14,9 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' -class ApigeeOrganizationEndpointAttachments < GcpResourceBase - name 'google_apigee_organization_endpoint_attachments' - desc 'OrganizationEndpointAttachment plural resource' +class ApigeeEndpointAttachments < GcpResourceBase + name 'google_apigee_endpoint_attachments' + desc 'EndpointAttachment plural resource' supports platform: 'gcp' attr_reader :table @@ -35,7 +35,7 @@ class ApigeeOrganizationEndpointAttachments < GcpResourceBase def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params - @table = fetch_wrapped_resource('organizationEndpointAttachments') + @table = fetch_wrapped_resource('endpointAttachments') end def fetch_wrapped_resource(wrap_path) @@ -84,6 +84,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+parent}}/endpointAttachments' + '{{parent}}/endpointAttachments' end end diff --git a/test/integration/verify/controls/google_apigee_endpoint_attachment.rb b/test/integration/verify/controls/google_apigee_endpoint_attachment.rb new file mode 100644 index 00000000..245d27ae --- /dev/null +++ b/test/integration/verify/controls/google_apigee_endpoint_attachment.rb @@ -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": "value_name", + "parent": "value_parent", + "host": "value_host", + "connection_state": "value_connectionstate", + "service_attachment": "value_serviceattachment", + "location": "value_location", + "state": "value_state" +}, 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 diff --git a/test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb b/test/integration/verify/controls/google_apigee_endpoint_attachments.rb similarity index 69% rename from test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb rename to test/integration/verify/controls/google_apigee_endpoint_attachments.rb index c8ebdc9b..b15e2fcd 100644 --- a/test/integration/verify/controls/google_apigee_organization_endpoint_attachments.rb +++ b/test/integration/verify/controls/google_apigee_endpoint_attachments.rb @@ -12,11 +12,11 @@ # # ---------------------------------------------------------------------------- -title 'Test GCP google_apigee_organization_endpoint_attachments resource.' +title 'Test GCP google_apigee_endpoint_attachments resource.' gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') - organization_endpoint_attachment = input('organization_endpoint_attachment', value: { + endpoint_attachment = input('endpoint_attachment', value: { "name": "value_name", "parent": "value_parent", "host": "value_host", @@ -24,12 +24,12 @@ "service_attachment": "value_serviceattachment", "location": "value_location", "state": "value_state" -}, description: 'organization_endpoint_attachment description') -control 'google_apigee_organization_endpoint_attachments-1.0' do +}, description: 'endpoint_attachment description') +control 'google_apigee_endpoint_attachments-1.0' do impact 1.0 - title 'google_apigee_organization_endpoint_attachments resource test' + title 'google_apigee_endpoint_attachments resource test' - describe google_apigee_organization_endpoint_attachments() do + describe google_apigee_endpoint_attachments() do it { should exist } end end diff --git a/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb b/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb deleted file mode 100644 index 01bafb1b..00000000 --- a/test/integration/verify/controls/google_apigee_organization_endpoint_attachment.rb +++ /dev/null @@ -1,46 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# *** 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_organization_endpoint_attachment resource.' - -gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') - - organization_endpoint_attachment = input('organization_endpoint_attachment', value: { - "name": "value_name", - "parent": "value_parent", - "host": "value_host", - "connection_state": "value_connectionstate", - "service_attachment": "value_serviceattachment", - "location": "value_location", - "state": "value_state" -}, description: 'organization_endpoint_attachment description') -control 'google_apigee_organization_endpoint_attachment-1.0' do - impact 1.0 - title 'google_apigee_organization_endpoint_attachment resource test' - - describe google_apigee_organization_endpoint_attachment(name: organization_endpoint_attachment['name']) do - it { should exist } - its('host') { should cmp organization_endpoint_attachment['host'] } - its('connection_state') { should cmp organization_endpoint_attachment['connection_state'] } - its('service_attachment') { should cmp organization_endpoint_attachment['service_attachment'] } - its('location') { should cmp organization_endpoint_attachment['location'] } - its('name') { should cmp organization_endpoint_attachment['name'] } - its('state') { should cmp organization_endpoint_attachment['state'] } - - end - - describe google_apigee_organization_endpoint_attachment(name: "does_not_exit") do - it { should_not exist } - end -end From bc0f6b138f625686724aa6fb62cb71dd631e68ea Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Thu, 29 Aug 2024 18:39:54 +0530 Subject: [PATCH 4/4] update test cases Signed-off-by: balasubramanian-s --- README.md | 3 ++- .../google_apigee_endpoint_attachments.md | 8 +++++++- .../google_apigee_endpoint_attachment.rb | 14 ++++++------- .../google_apigee_endpoint_attachments.rb | 20 ++++++++++++------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 67095f07..0ff52772 100644 --- a/README.md +++ b/README.md @@ -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) | diff --git a/docs/resources/google_apigee_endpoint_attachments.md b/docs/resources/google_apigee_endpoint_attachments.md index a157f393..8fb4f937 100644 --- a/docs/resources/google_apigee_endpoint_attachments.md +++ b/docs/resources/google_apigee_endpoint_attachments.md @@ -23,8 +23,14 @@ A `google_apigee_endpoint_attachments` is used to test a Google EndpointAttachme ## Examples ``` - describe google_apigee_endpoint_attachments() do + 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 ``` diff --git a/test/integration/verify/controls/google_apigee_endpoint_attachment.rb b/test/integration/verify/controls/google_apigee_endpoint_attachment.rb index 245d27ae..a968f7e1 100644 --- a/test/integration/verify/controls/google_apigee_endpoint_attachment.rb +++ b/test/integration/verify/controls/google_apigee_endpoint_attachment.rb @@ -17,13 +17,13 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') endpoint_attachment = input('endpoint_attachment', value: { - "name": "value_name", - "parent": "value_parent", - "host": "value_host", - "connection_state": "value_connectionstate", - "service_attachment": "value_serviceattachment", - "location": "value_location", - "state": "value_state" + "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 diff --git a/test/integration/verify/controls/google_apigee_endpoint_attachments.rb b/test/integration/verify/controls/google_apigee_endpoint_attachments.rb index b15e2fcd..8e1a2b3e 100644 --- a/test/integration/verify/controls/google_apigee_endpoint_attachments.rb +++ b/test/integration/verify/controls/google_apigee_endpoint_attachments.rb @@ -17,13 +17,13 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') endpoint_attachment = input('endpoint_attachment', value: { - "name": "value_name", - "parent": "value_parent", - "host": "value_host", - "connection_state": "value_connectionstate", - "service_attachment": "value_serviceattachment", - "location": "value_location", - "state": "value_state" + "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 @@ -31,5 +31,11 @@ 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