From 3e8b8e4f2cba5ebe033c159056b1fac9fa72837d Mon Sep 17 00:00:00 2001 From: Samir Anand Date: Thu, 7 Sep 2023 19:14:32 +0530 Subject: [PATCH] Automatically generated by magic modules for service: compute and resource: PublicDelegatedPrefix. This commit includes the following changes: - Singular Resource - Plural Resource - Documentation updates - Terraform configuration - Integration tests Signed-off-by: Samir Anand --- build/inspec/test/integration/build/gcp-mm.tf | 39 ------------ .../configuration/mm-attributes.yml | 14 +++-- .../google_compute_public_delegated_prefix.md | 48 +++++++++++---- ...oogle_compute_public_delegated_prefixes.md | 16 +++-- ...atedprefix_public_delegated_sub_prefixs.rb | 60 +++++++++++++++++++ .../google_compute_public_delegated_prefix.rb | 28 +++++---- ...oogle_compute_public_delegated_prefixes.rb | 27 +++++---- .../google_compute_public_delegated_prefix.rb | 13 ++-- ...oogle_compute_public_delegated_prefixes.rb | 13 ++-- 9 files changed, 160 insertions(+), 98 deletions(-) create mode 100644 libraries/google/compute/property/publicdelegatedprefix_public_delegated_sub_prefixs.rb diff --git a/build/inspec/test/integration/build/gcp-mm.tf b/build/inspec/test/integration/build/gcp-mm.tf index 382383935..939785bc7 100644 --- a/build/inspec/test/integration/build/gcp-mm.tf +++ b/build/inspec/test/integration/build/gcp-mm.tf @@ -1345,42 +1345,3 @@ resource "google_data_loss_prevention_stored_info_type" "basic" { group_indexes = [2] } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/inspec/test/integration/configuration/mm-attributes.yml b/build/inspec/test/integration/configuration/mm-attributes.yml index 1726d1f03..c98741409 100644 --- a/build/inspec/test/integration/configuration/mm-attributes.yml +++ b/build/inspec/test/integration/configuration/mm-attributes.yml @@ -5,7 +5,7 @@ ssl_policy: custom_feature: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' custom_feature2: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' -topic: +topic: name: 'inspec-gcp-topic' subscription: @@ -232,7 +232,7 @@ standardappversion: runtime: nodejs10 entrypoint: "node ./app.js" port: "8080" - + ml_model: name: ml_model region: us-central1 @@ -338,7 +338,7 @@ spannerinstance: spannerdatabase: name: spdatabase instance: spinstance - ddl: "CREATE TABLE test (test STRING(MAX),) PRIMARY KEY (test)" + ddl: "CREATE TABLE test (test STRING(MAX),) PRIMARY KEY (test)" scheduler_job: # region must match where the appengine instance is deployed @@ -437,7 +437,7 @@ logging_metric: compute_image: name: inspec-image source: https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz - + security_policy: name: sec-policy action: deny(403) @@ -492,7 +492,7 @@ sql_database_flag: applies_to: MYSQL_5_6 allowed_string_values: ON requires_restart: true - + sql_connect: region: us-central1 database_version: POSTGRES_13 @@ -536,6 +536,10 @@ dlp: job_trigger_name: "name1" job_trigger_display_name: "dp" job_trigger_description: "description" + deidentify_templates: + name: "dlp-template-inspec" + location: "europe-west2" + type: "Infotype" diff --git a/docs/resources/google_compute_public_delegated_prefix.md b/docs/resources/google_compute_public_delegated_prefix.md index 1b015582b..54a49a16a 100644 --- a/docs/resources/google_compute_public_delegated_prefix.md +++ b/docs/resources/google_compute_public_delegated_prefix.md @@ -8,38 +8,62 @@ A `google_compute_public_delegated_prefix` is used to test a Google PublicDelega ## Examples ``` -describe google_compute_public_delegated_prefix(project: 'chef-gcp-inspec', region: 'us-east1-b', name: 'test') do - it { should exist } -end + describe google_compute_public_delegated_prefix(project: 'chef-gcp-inspec', region: ' ', publicDelegatedPrefix: ' ') do + it { should exist } + end ``` ## Properties Properties that can be accessed from the `google_compute_public_delegated_prefix` resource: - * `creation_timestamp`: Creation timestamp in RFC3339 text format.This field is deprecated. + * `kind`: Type of the resource. Always compute#publicDelegatedPrefix for public delegated prefixes. - * `description`: An optional description of this resource. Provide this property when you create the resource. + * `id`: string (uint64 format) The unique identifier for the resource type. The server generates this identifier. - * `id`: The unique identifier for the resource. + * `creation_timestamp`: Creation timestamp in RFC3339 text format. - * `name`: 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. + * `name`: 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. - * `ip_cidr_range`: The IPv4 address range, in CIDR format, represented by this public delegated prefix. + * `description`: An optional description of this resource. Provide this property when you create the resource. - * `parent_prefix`: The value of requestId if you provided it in the request. Not present otherwise. + * `self_link`: Server-defined URL for the resource. - * `is_live_migration`: If true, the prefix will be live migrated. + * `region`: URL of the region where the public delegated prefix resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. - * `fingerprint`: Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a new PublicDelegatedPrefix. An up-to-date fingerprint must be provided in order to update the PublicDelegatedPrefix, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a PublicDelegatedPrefix. A base64-encoded string. + * `ip_cidr_range`: The IP address range, in CIDR format, represented by this public delegated prefix. - * `status`: The status of the public delegated prefix, which can be one of following values: * INITIALIZING The public delegated prefix is being initialized and addresses cannot be created yet. * READY_TO_ANNOUNCE The public delegated prefix is a live migration prefix and is active. * ANNOUNCED The public delegated prefix is active. * DELETING The public delegated prefix is being deprovsioned. + * `status`: The status of the public delegated prefix, which can be one of following values: INITIALIZING The public delegated prefix is being initialized and addresses cannot be created yet. READY_TO_ANNOUNCE The public delegated prefix is a live migration prefix and is active. ANNOUNCED The public delegated prefix is active. DELETING The public delegated prefix is being deprovsioned. Possible values: * INITIALIZING * READY_TO_ANNOUNCE * ANNOUNCED * DELETING + * `parent_prefix`: The URL of parent prefix. Either PublicAdvertisedPrefix or PublicDelegatedPrefix. + + * `public_delegated_sub_prefixs`: object The list of sub public delegated prefixes that exist for this public delegated prefix. + + * `name`: The name of the sub public delegated prefix. + + * `description`: An optional description of this resource. Provide this property when you create the resource. + + * `region`: The region of the sub public delegated prefix if it is regional. If absent, the sub prefix is global. + + * `status`: The status of the sub public delegated prefix. + Possible values: + * VALUE_1 + + * `ip_cidr_range`: The IP address range, in CIDR format, represented by this sub public delegated prefix. + + * `delegatee_project`: Name of the project scoping this PublicDelegatedSubPrefix. + + * `is_address`: boolean Whether the sub prefix is delegated to create Address resources in the delegatee project. + + * `is_live_migration`: boolean If true, the prefix will be live migrated. + + * `fingerprint`: string (bytes format) Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. This field will be ignored when inserting a new PublicDelegatedPrefix. An up-to-date fingerprint must be provided in order to update the PublicDelegatedPrefix, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a PublicDelegatedPrefix. A base64-encoded string. + ## GCP Permissions diff --git a/docs/resources/google_compute_public_delegated_prefixes.md b/docs/resources/google_compute_public_delegated_prefixes.md index 9b3a258d0..1cd8ee8bc 100644 --- a/docs/resources/google_compute_public_delegated_prefixes.md +++ b/docs/resources/google_compute_public_delegated_prefixes.md @@ -8,24 +8,28 @@ A `google_compute_public_delegated_prefixes` is used to test a Google PublicDele ## Examples ``` -describe google_compute_public_delegated_prefixes(project: 'chef-gcp-inspec', region: 'us-east1-b') do - it { should exist } -end + describe google_compute_public_delegated_prefix(project: 'chef-gcp-inspec', region: ' ') do + it { should exist } + end ``` ## Properties Properties that can be accessed from the `google_compute_public_delegated_prefixes` resource: See [google_compute_public_delegated_prefix.md](google_compute_public_delegated_prefix.md) for more detailed information - * `creation_timestamps`: an array of `google_compute_public_delegated_prefix` creation_timestamp - * `descriptions`: an array of `google_compute_public_delegated_prefix` description + * `kinds`: an array of `google_compute_public_delegated_prefix` kind * `ids`: an array of `google_compute_public_delegated_prefix` id + * `creation_timestamps`: an array of `google_compute_public_delegated_prefix` creation_timestamp * `names`: an array of `google_compute_public_delegated_prefix` name + * `descriptions`: an array of `google_compute_public_delegated_prefix` description + * `self_links`: an array of `google_compute_public_delegated_prefix` self_link + * `regions`: an array of `google_compute_public_delegated_prefix` region * `ip_cidr_ranges`: an array of `google_compute_public_delegated_prefix` ip_cidr_range + * `statuses`: an array of `google_compute_public_delegated_prefix` status * `parent_prefixes`: an array of `google_compute_public_delegated_prefix` parent_prefix + * `public_delegated_sub_prefixs`: an array of `google_compute_public_delegated_prefix` public_delegated_sub_prefixs * `is_live_migrations`: an array of `google_compute_public_delegated_prefix` is_live_migration * `fingerprints`: an array of `google_compute_public_delegated_prefix` fingerprint - * `statuses`: an array of `google_compute_public_delegated_prefix` status ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used diff --git a/libraries/google/compute/property/publicdelegatedprefix_public_delegated_sub_prefixs.rb b/libraries/google/compute/property/publicdelegatedprefix_public_delegated_sub_prefixs.rb new file mode 100644 index 000000000..3141510d9 --- /dev/null +++ b/libraries/google/compute/property/publicdelegatedprefix_public_delegated_sub_prefixs.rb @@ -0,0 +1,60 @@ +# 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. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Compute + module Property + class PublicDelegatedPrefixPublicDelegatedSubPrefixs + attr_reader :name + + attr_reader :description + + attr_reader :region + + attr_reader :status + + attr_reader :ip_cidr_range + + attr_reader :delegatee_project + + attr_reader :is_address + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @name = args['name'] + @description = args['description'] + @region = args['region'] + @status = args['status'] + @ip_cidr_range = args['ipCidrRange'] + @delegatee_project = args['delegateeProject'] + @is_address = args['isAddress'] + end + + def to_s + "#{@parent_identifier} PublicDelegatedPrefixPublicDelegatedSubPrefixs" + end + end + + class PublicDelegatedPrefixPublicDelegatedSubPrefixsArray + def self.parse(value, parent_identifier) + return if value.nil? + return PublicDelegatedPrefixPublicDelegatedSubPrefixs.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| PublicDelegatedPrefixPublicDelegatedSubPrefixs.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google_compute_public_delegated_prefix.rb b/libraries/google_compute_public_delegated_prefix.rb index 8d1e8646f..2f0c04c99 100644 --- a/libraries/google_compute_public_delegated_prefix.rb +++ b/libraries/google_compute_public_delegated_prefix.rb @@ -14,6 +14,7 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' +require 'google/compute/property/publicdelegatedprefix_public_delegated_sub_prefixs' # A provider to manage Compute Engine resources. class ComputePublicDelegatedPrefix < GcpResourceBase @@ -22,15 +23,19 @@ class ComputePublicDelegatedPrefix < GcpResourceBase supports platform: 'gcp' attr_reader :params - attr_reader :creation_timestamp - attr_reader :description + attr_reader :kind attr_reader :id + attr_reader :creation_timestamp attr_reader :name + attr_reader :description + attr_reader :self_link + attr_reader :region attr_reader :ip_cidr_range + attr_reader :status attr_reader :parent_prefix + attr_reader :public_delegated_sub_prefixs attr_reader :is_live_migration attr_reader :fingerprint - attr_reader :status def initialize(params) super(params.merge({ use_http_transport: true })) @@ -40,20 +45,19 @@ def initialize(params) end def parse - @creation_timestamp = parse_time_string(@fetched['creationTimestamp']) - @description = @fetched['description'] + @kind = @fetched['kind'] @id = @fetched['id'] + @creation_timestamp = @fetched['creationTimestamp'] @name = @fetched['name'] + @description = @fetched['description'] + @self_link = @fetched['selfLink'] + @region = @fetched['region'] @ip_cidr_range = @fetched['ipCidrRange'] + @status = @fetched['status'] @parent_prefix = @fetched['parentPrefix'] + @public_delegated_sub_prefixs = GoogleInSpec::Compute::Property::PublicDelegatedPrefixPublicDelegatedSubPrefixsArray.parse(@fetched['publicDelegatedSubPrefixs'], to_s) @is_live_migration = @fetched['isLiveMigration'] @fingerprint = @fetched['fingerprint'] - @status = @fetched['status'] - end - - # Handles parsing RFC3339 time string - def parse_time_string(time_string) - time_string ? Time.parse(time_string) : nil end def exists? @@ -71,6 +75,6 @@ def product_url(_ = nil) end def resource_base_url - 'projects/{{project}}/regions/{{region}}/publicDelegatedPrefixes/{{name}}' + 'projects/{{project}}/regions/{{region}}/publicDelegatedPrefixes/{{public_delegated_prefix}}/{{name}}' end end diff --git a/libraries/google_compute_public_delegated_prefixes.rb b/libraries/google_compute_public_delegated_prefixes.rb index e71a11715..47f796690 100644 --- a/libraries/google_compute_public_delegated_prefixes.rb +++ b/libraries/google_compute_public_delegated_prefixes.rb @@ -23,15 +23,19 @@ class ComputePublicDelegatedPrefixs < GcpResourceBase filter_table_config = FilterTable.create - filter_table_config.add(:creation_timestamps, field: :creation_timestamp) - filter_table_config.add(:descriptions, field: :description) + filter_table_config.add(:kinds, field: :kind) filter_table_config.add(:ids, field: :id) + filter_table_config.add(:creation_timestamps, field: :creation_timestamp) filter_table_config.add(:names, field: :name) + filter_table_config.add(:descriptions, field: :description) + filter_table_config.add(:self_links, field: :self_link) + filter_table_config.add(:regions, field: :region) filter_table_config.add(:ip_cidr_ranges, field: :ip_cidr_range) + filter_table_config.add(:statuses, field: :status) filter_table_config.add(:parent_prefixes, field: :parent_prefix) + filter_table_config.add(:public_delegated_sub_prefixs, field: :public_delegated_sub_prefixs) filter_table_config.add(:is_live_migrations, field: :is_live_migration) filter_table_config.add(:fingerprints, field: :fingerprint) - filter_table_config.add(:statuses, field: :status) filter_table_config.connect(self, :table) @@ -71,23 +75,22 @@ def transform(key, value) def transformers { - 'creationTimestamp' => ->(obj) { return :creation_timestamp, parse_time_string(obj['creationTimestamp']) }, - 'description' => ->(obj) { return :description, obj['description'] }, + 'kind' => ->(obj) { return :kind, obj['kind'] }, 'id' => ->(obj) { return :id, obj['id'] }, + 'creationTimestamp' => ->(obj) { return :creation_timestamp, obj['creationTimestamp'] }, 'name' => ->(obj) { return :name, obj['name'] }, + 'description' => ->(obj) { return :description, obj['description'] }, + 'selfLink' => ->(obj) { return :self_link, obj['selfLink'] }, + 'region' => ->(obj) { return :region, obj['region'] }, 'ipCidrRange' => ->(obj) { return :ip_cidr_range, obj['ipCidrRange'] }, + 'status' => ->(obj) { return :status, obj['status'] }, 'parentPrefix' => ->(obj) { return :parent_prefix, obj['parentPrefix'] }, + 'publicDelegatedSubPrefixs' => ->(obj) { return :public_delegated_sub_prefixs, GoogleInSpec::Compute::Property::PublicDelegatedPrefixPublicDelegatedSubPrefixsArray.parse(obj['publicDelegatedSubPrefixs'], to_s) }, 'isLiveMigration' => ->(obj) { return :is_live_migration, obj['isLiveMigration'] }, 'fingerprint' => ->(obj) { return :fingerprint, obj['fingerprint'] }, - 'status' => ->(obj) { return :status, obj['status'] }, } end - # Handles parsing RFC3339 time string - def parse_time_string(time_string) - time_string ? Time.parse(time_string) : nil - end - private def product_url(_ = nil) @@ -95,6 +98,6 @@ def product_url(_ = nil) end def resource_base_url - 'projects/{{project}}/regions/{{region}}/publicDelegatedPrefixes' + 'projects/{{project}}/regions/{{region}}/publicDelegatedPrefixes/{{publicDelegatedPrefix}}' end end diff --git a/test/integration/verify/controls/google_compute_public_delegated_prefix.rb b/test/integration/verify/controls/google_compute_public_delegated_prefix.rb index c7e0e0e40..577e8e2b2 100644 --- a/test/integration/verify/controls/google_compute_public_delegated_prefix.rb +++ b/test/integration/verify/controls/google_compute_public_delegated_prefix.rb @@ -14,15 +14,16 @@ title 'Test GCP google_compute_public_delegated_prefix resource.' -gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') -public_delegated_prefix = attribute('public_delegated_prefix', default: { +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + public_delegated_prefix = input('public_delegated_prefix', value: { "name": "test" -}, description: 'PublicDelegatedPrefix resource in the given region') +}, description: 'public_delegated_prefix description') control 'google_compute_public_delegated_prefix-1.0' do impact 1.0 title 'google_compute_public_delegated_prefix resource test' - describe google_compute_public_delegated_prefix(project: gcp_project_id, region: 'us-east1-b', name: public_delegated_prefix['name']) do - it { should exist } - end + describe google_compute_public_delegated_prefix(project: gcp_project_id, region: public_delegated_prefix['region'], publicDelegatedPrefix: public_delegated_prefix['publicDelegatedPrefix']) do + it { should exist } + end end diff --git a/test/integration/verify/controls/google_compute_public_delegated_prefixes.rb b/test/integration/verify/controls/google_compute_public_delegated_prefixes.rb index 119f535a2..eb90f14fb 100644 --- a/test/integration/verify/controls/google_compute_public_delegated_prefixes.rb +++ b/test/integration/verify/controls/google_compute_public_delegated_prefixes.rb @@ -14,15 +14,16 @@ title 'Test GCP google_compute_public_delegated_prefixes resource.' -gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') -public_delegated_prefix = attribute('public_delegated_prefix', default: { +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + public_delegated_prefix = input('public_delegated_prefix', value: { "name": "test" -}, description: 'PublicDelegatedPrefix resource in the given region') +}, description: 'public_delegated_prefix description') control 'google_compute_public_delegated_prefixes-1.0' do impact 1.0 title 'google_compute_public_delegated_prefixes resource test' - describe google_compute_public_delegated_prefixes(project: gcp_project_id, region: 'us-east1-b') do - it { should exist } - end + describe google_compute_public_delegated_prefix(project: gcp_project_id, region: public_delegated_prefix['region']) do + it { should exist } + end end