From 8f653596868b4267ff75ba16e7fd301f37298adf Mon Sep 17 00:00:00 2001 From: Samir Anand Date: Wed, 13 Dec 2023 20:49:26 +0530 Subject: [PATCH] Automatically generated by magic modules for service: cloudkms and resource: Projects__locations__keyRing. This commit includes the following changes: - Singular Resource - Plural Resource - Documentation updates - Terraform configuration - Integration tests Signed-off-by: Samir Anand --- ...ogle_cloudkms_project_location_key_ring.md | 34 ++++++++ ...gle_cloudkms_project_location_key_rings.md | 29 +++++++ ...ogle_cloudkms_project_location_key_ring.rb | 57 +++++++++++++ ...gle_cloudkms_project_location_key_rings.rb | 81 +++++++++++++++++++ ...ogle_cloudkms_project_location_key_ring.rb | 38 +++++++++ ...gle_cloudkms_project_location_key_rings.rb | 31 +++++++ 6 files changed, 270 insertions(+) create mode 100644 docs/resources/google_cloudkms_project_location_key_ring.md create mode 100644 docs/resources/google_cloudkms_project_location_key_rings.md create mode 100644 libraries/google_cloudkms_project_location_key_ring.rb create mode 100644 libraries/google_cloudkms_project_location_key_rings.rb create mode 100644 test/integration/verify/controls/google_cloudkms_project_location_key_ring.rb create mode 100644 test/integration/verify/controls/google_cloudkms_project_location_key_rings.rb diff --git a/docs/resources/google_cloudkms_project_location_key_ring.md b/docs/resources/google_cloudkms_project_location_key_ring.md new file mode 100644 index 000000000..d85d4e52e --- /dev/null +++ b/docs/resources/google_cloudkms_project_location_key_ring.md @@ -0,0 +1,34 @@ +--- +title: About the google_cloudkms_project_location_key_ring resource +platform: gcp +--- + +## Syntax +A `google_cloudkms_project_location_key_ring` is used to test a Google ProjectLocationKeyRing resource + +## Examples +``` +describe google_cloudkms_project_location_key_ring(name: ' value_name') do + it { should exist } + its('name') { should cmp 'value_name' } + its('create_time') { should cmp 'value_createtime' } + +end + +describe google_cloudkms_project_location_key_ring(name: "does_not_exit") do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_cloudkms_project_location_key_ring` resource: + + + * `name`: Output only. The resource name for the KeyRing in the format `projects/*/locations/*/keyRings/*`. + + * `create_time`: Output only. The time at which this KeyRing was created. + + +## GCP Permissions + +Ensure the [https://cloudkms.googleapis.com/](https://console.cloud.google.com/apis/library/cloudkms.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_cloudkms_project_location_key_rings.md b/docs/resources/google_cloudkms_project_location_key_rings.md new file mode 100644 index 000000000..3178b4dc0 --- /dev/null +++ b/docs/resources/google_cloudkms_project_location_key_rings.md @@ -0,0 +1,29 @@ +--- +title: About the google_cloudkms_project_location_key_rings resource +platform: gcp +--- + +## Syntax +A `google_cloudkms_project_location_key_rings` is used to test a Google ProjectLocationKeyRing resource + +## Examples +``` + describe google_cloudkms_project_location_key_rings() do + it { should exist } + end +``` + +## Properties +Properties that can be accessed from the `google_cloudkms_project_location_key_rings` resource: + +See [google_cloudkms_project_location_key_ring.md](google_cloudkms_project_location_key_ring.md) for more detailed information + * `names`: an array of `google_cloudkms_project_location_key_ring` name + * `create_times`: an array of `google_cloudkms_project_location_key_ring` create_time + +## 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 [https://cloudkms.googleapis.com/](https://console.cloud.google.com/apis/library/cloudkms.googleapis.com/) is enabled for the current project. diff --git a/libraries/google_cloudkms_project_location_key_ring.rb b/libraries/google_cloudkms_project_location_key_ring.rb new file mode 100644 index 000000000..714abf52e --- /dev/null +++ b/libraries/google_cloudkms_project_location_key_ring.rb @@ -0,0 +1,57 @@ +# 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 cloudkms resources. +class CloudkmsProjectLocationKeyRing < GcpResourceBase + name 'google_cloudkms_project_location_key_ring' + desc 'ProjectLocationKeyRing' + supports platform: 'gcp' + + attr_reader :params + attr_reader :name + attr_reader :create_time + + 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 + @name = @fetched['name'] + @create_time = @fetched['createTime'] + end + + def exists? + !@fetched.nil? + end + + def to_s + "ProjectLocationKeyRing #{@params[:name]}" + end + + private + + def product_url(_ = nil) + 'https://cloudkms.googleapis.com//v1/' + end + + def resource_base_url + '{{name}}' + end +end diff --git a/libraries/google_cloudkms_project_location_key_rings.rb b/libraries/google_cloudkms_project_location_key_rings.rb new file mode 100644 index 000000000..dd26d735e --- /dev/null +++ b/libraries/google_cloudkms_project_location_key_rings.rb @@ -0,0 +1,81 @@ +# 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 CloudkmsProjectLocationKeyRings < GcpResourceBase + name 'google_cloudkms_project_location_key_rings' + desc 'ProjectLocationKeyRing plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:names, field: :name) + filter_table_config.add(:create_times, field: :create_time) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('projectLocationKeyRings') + 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 + { + 'name' => ->(obj) { [:name, obj['name']] }, + 'createTime' => ->(obj) { [:create_time, obj['createTime']] }, + } + end + + private + + def product_url(_ = nil) + 'https://cloudkms.googleapis.com//v1/' + end + + def resource_base_url + '{{parent}}/keyRings' + end +end diff --git a/test/integration/verify/controls/google_cloudkms_project_location_key_ring.rb b/test/integration/verify/controls/google_cloudkms_project_location_key_ring.rb new file mode 100644 index 000000000..396b4cda4 --- /dev/null +++ b/test/integration/verify/controls/google_cloudkms_project_location_key_ring.rb @@ -0,0 +1,38 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_cloudkms_project_location_key_ring resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_location_key_ring = input('project_location_key_ring', value: { + "name": "value_name", + "parent": "value_parent", + "create_time": "value_createtime" +}, description: 'project_location_key_ring description') +control 'google_cloudkms_project_location_key_ring-1.0' do + impact 1.0 + title 'google_cloudkms_project_location_key_ring resource test' + + describe google_cloudkms_project_location_key_ring(name: project_location_key_ring['name']) do + it { should exist } + its('name') { should cmp project_location_key_ring['name'] } + its('create_time') { should cmp project_location_key_ring['create_time'] } + + end + + describe google_cloudkms_project_location_key_ring(name: "does_not_exit") do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_cloudkms_project_location_key_rings.rb b/test/integration/verify/controls/google_cloudkms_project_location_key_rings.rb new file mode 100644 index 000000000..c63110c2b --- /dev/null +++ b/test/integration/verify/controls/google_cloudkms_project_location_key_rings.rb @@ -0,0 +1,31 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_cloudkms_project_location_key_rings resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_location_key_ring = input('project_location_key_ring', value: { + "name": "value_name", + "parent": "value_parent", + "create_time": "value_createtime" +}, description: 'project_location_key_ring description') +control 'google_cloudkms_project_location_key_rings-1.0' do + impact 1.0 + title 'google_cloudkms_project_location_key_rings resource test' + + describe google_cloudkms_project_location_key_rings() do + it { should exist } + end +end