diff --git a/docs/resources/google_apigee_organization_api_revision.md b/docs/resources/google_apigee_organization_api_revision.md new file mode 100644 index 000000000..1091e2803 --- /dev/null +++ b/docs/resources/google_apigee_organization_api_revision.md @@ -0,0 +1,36 @@ +--- +title: About the google_apigee_organization_api_revision resource +platform: gcp +--- + +## Syntax +A `google_apigee_organization_api_revision` is used to test a Google OrganizationApiRevision resource + +## Examples +``` +describe google_apigee_organization_api_revision(name: ' value_name') do + it { should exist } + its('content_type') { should cmp 'value_contenttype' } + its('data') { should cmp 'value_data' } + +end + +describe google_apigee_organization_api_revision(name: "does_not_exit") do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_apigee_organization_api_revision` resource: + + + * `extensions`: Application specific response metadata. Must be set in the first response for streaming APIs. + + * `content_type`: The HTTP Content-Type header value specifying the content type of the body. + + * `data`: The HTTP request/response body as raw binary. + + +## 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_api_revisions.md b/docs/resources/google_apigee_organization_api_revisions.md new file mode 100644 index 000000000..c625c8f51 --- /dev/null +++ b/docs/resources/google_apigee_organization_api_revisions.md @@ -0,0 +1,30 @@ +--- +title: About the google_apigee_organization_api_revisions resource +platform: gcp +--- + +## Syntax +A `google_apigee_organization_api_revisions` is used to test a Google OrganizationApiRevision resource + +## Examples +``` + describe google_apigee_organization_api_revisions() do + it { should exist } + end +``` + +## Properties +Properties that can be accessed from the `google_apigee_organization_api_revisions` resource: + +See [google_apigee_organization_api_revision.md](google_apigee_organization_api_revision.md) for more detailed information + * `extensions`: an array of `google_apigee_organization_api_revision` extensions + * `content_types`: an array of `google_apigee_organization_api_revision` content_type + * `data`: an array of `google_apigee_organization_api_revision` data + +## 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/gcp_backend.rb b/libraries/gcp_backend.rb index 0fdb7a081..7817e8bbe 100644 --- a/libraries/gcp_backend.rb +++ b/libraries/gcp_backend.rb @@ -245,6 +245,9 @@ def next_page(uri, request_type, token = nil) request_type, ) result = return_if_object(get_request.send) + if result.is_a?(Array) + return result + end next_page_token = result['nextPageToken'] return [result] if next_page_token.nil? diff --git a/libraries/google_apigee_organization_api_revision.rb b/libraries/google_apigee_organization_api_revision.rb new file mode 100644 index 000000000..8ea7d5db6 --- /dev/null +++ b/libraries/google_apigee_organization_api_revision.rb @@ -0,0 +1,73 @@ +# 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 ApigeeOrganizationApiRevision < GcpResourceBase + name 'google_apigee_organization_api_revision' + desc 'OrganizationApiRevision' + supports platform: 'gcp' + + attr_reader :params + attr_reader :description + attr_reader :created_at + attr_reader :configuration_version + attr_reader :policies + attr_reader :entity_meta_data_as_properties + attr_reader :type + attr_reader :proxies + attr_reader :revision + attr_reader :name + attr_reader :last_modified_at + + 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 + @policies = @fetched['policies'] + @configuration_version = @fetched['configurationVersion'] + @created_at = @fetched['createdAt'] + @description = @fetched['description'] + @entity_meta_data_as_properties = @fetched['entityMetaDataAsProperties'] + @last_modified_at = @fetched['lastModifiedAt'] + @name = @fetched['name'] + @revision = @fetched['revision'] + @proxies = @fetched['proxies'] + @type = @fetched['type'] + end + + def exists? + !@fetched.nil? + end + + def to_s + "OrganizationApiRevision #{@params[:name]}" + 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_api_revisions.rb b/libraries/google_apigee_organization_api_revisions.rb new file mode 100644 index 000000000..61bbade29 --- /dev/null +++ b/libraries/google_apigee_organization_api_revisions.rb @@ -0,0 +1,69 @@ +# 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 ApigeeOrganizationApiRevisions < GcpResourceBase + name 'google_apigee_organization_api_revisions' + desc 'OrganizationApiRevision plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:extensions, field: :extensions) + filter_table_config.add(:content_types, field: :content_type) + filter_table_config.add(:data, field: :data) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('organizationApiRevisions') + end + + def fetch_wrapped_resource(wrap_path) + # fetch_resource returns an array of responses (to handle pagination) + @connection.fetch_all(product_url, resource_base_url, @params, 'Get') + end + + def revisions + @table + end + def transform(key, value) + return transformers[key].call(value) if transformers.key?(key) + + [key.to_sym, value] + end + + def transformers + { + 'extensions' => ->(obj) { [:extensions, obj['extensions']] }, + 'contentType' => ->(obj) { [:content_type, obj['contentType']] }, + 'data' => ->(obj) { [:data, obj['data']] }, + } + end + + private + + def product_url(_ = nil) + 'https://apigee.googleapis.com/v1/' + end + + def resource_base_url + '{{parent}}/revisions' + end +end diff --git a/libraries/google_compute_regions.rb b/libraries/google_compute_regions.rb index 5878bc619..049580496 100644 --- a/libraries/google_compute_regions.rb +++ b/libraries/google_compute_regions.rb @@ -58,7 +58,6 @@ def fetch_wrapped_resource(wrap_path) converted.push(hash_with_symbols) end end - converted end diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index 54499a479..71422884a 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -640,3 +640,10 @@ crypto_key_version: key_ring: "gcp-inspec-kms-key-ring" crypto_key: "gcp-inspec-kms-crypto-key-policy" region: "us-central-1" + +organization_api_revision: + name: "organizations/ppradhan/apis/helloworld/revisions/1" + parent: "organizations/ppradhan/apis/helloworld" + content_type: "Application" + revision: 1 + api: "helloworld" diff --git a/test/integration/verify/controls/google_apigee_organization_api_revision.rb b/test/integration/verify/controls/google_apigee_organization_api_revision.rb new file mode 100644 index 000000000..2d199c01e --- /dev/null +++ b/test/integration/verify/controls/google_apigee_organization_api_revision.rb @@ -0,0 +1,39 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_api_revision resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + +organization_api_revision = input('organization_api_revision', value: { + "name": "organizations/{organization}/apis/{api}/revisions/{revision}", + "content_type": "Application", + "data": "value_data", + "revision": 1, +}, description: 'organization_api_revision description') +control 'google_apigee_organization_api_revision-1.0' do + impact 1.0 + title 'google_apigee_organization_api_revision resource test' + + describe google_apigee_organization_api_revision(name: organization_api_revision['name']) do + it { should exist } + its('type') { should cmp organization_api_revision['content_type'] } + its('revision') { should cmp organization_api_revision['revision'] } + end + + describe google_apigee_organization_api_revision(name: "does_not_exit") do + it { should_not exist } + end +end + diff --git a/test/integration/verify/controls/google_apigee_organization_api_revisions.rb b/test/integration/verify/controls/google_apigee_organization_api_revisions.rb new file mode 100644 index 000000000..1159b28af --- /dev/null +++ b/test/integration/verify/controls/google_apigee_organization_api_revisions.rb @@ -0,0 +1,44 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_api_revisions resource.' +# +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + +organization_api_revision = input('organization_api_revision', value: { + "parent": "organizations/ppradhan/apis/helloworld", + "name": "organizations/{organization}/apis/{api}/revisions/{revision}", + "content_type": "Application", + "data": "value_data", + "revision": 1, + "api": "helloworld" +}, description: 'organization_api_revision description') + +control 'google_apigee_organization_api_revisions-1.0' do + impact 1.0 + title 'google_apigee_organization_api_revisions resource test' + + describe google_apigee_organization_api_revisions(parent: organization_api_revision['parent']) do + it { should exist } + its('revisions') { should include "1" } + end + + google_apigee_organization_api_revisions(parent: organization_api_revision['parent']).revisions.each do |rev| + describe google_apigee_organization_api_revision(name: "organizations/#{gcp_project_id}/apis/#{api}/revisions/#{rev}") do + it { should exist } + its('type') { should cmp organization_api_revision['content_type'] } + its('revision') { should cmp organization_api_revision['revision'] } + end + end +end