diff --git a/docs/resources/google_compute_region_notification_endpoint.md b/docs/resources/google_compute_region_notification_endpoint.md new file mode 100644 index 000000000..a4aaa6308 --- /dev/null +++ b/docs/resources/google_compute_region_notification_endpoint.md @@ -0,0 +1,65 @@ +--- +title: About the google_compute_region_notification_endpoint resource +platform: gcp +--- + +## Syntax +A `google_compute_region_notification_endpoint` is used to test a Google RegionNotificationEndpoint resource + +## Examples +``` +describe google_compute_region_notification_endpoint(notificationEndpoint: ' ', project: 'chef-gcp-inspec', region: ' value_region') do + it { should exist } + its('kind') { should cmp 'value_kind' } + its('id') { should cmp 'value_id' } + its('creation_timestamp') { should cmp 'value_creationtimestamp' } + its('name') { should cmp 'value_name' } + its('description') { should cmp 'value_description' } + its('self_link') { should cmp 'value_selflink' } + its('region') { should cmp 'value_region' } + +end + +describe google_compute_region_notification_endpoint(notificationEndpoint: ' ', project: 'chef-gcp-inspec', region: ' value_region') do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_compute_region_notification_endpoint` resource: + + + * `kind`: [Output Only] Type of the resource. Always compute#notificationEndpoint for notification endpoints. + + * `id`: [Output Only] A unique identifier for this resource type. The server generates this identifier. + + * `creation_timestamp`: [Output Only] 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. + + * `description`: An optional description of this resource. Provide this property when you create the resource. + + * `self_link`: [Output Only] Server-defined URL for the resource. + + * `region`: [Output Only] URL of the region where the notification endpoint resides. This field applies only to the regional resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body. + + * `grpc_settings`: Represents a gRPC setting that describes one gRPC notification endpoint and the retry duration attempting to send notification to this endpoint. + + * `endpoint`: Endpoint to which gRPC notifications are sent. This must be a valid gRPCLB DNS name. + + * `retry_duration_sec`: How much time (in seconds) is spent attempting notification retries until a successful response is received. Default is 30s. Limit is 20m (1200s). Must be a positive number. + + * `payload_name`: Optional. If specified, this field is used to populate the "name" field in gRPC requests. + + * `authority`: Optional. If specified, this field is used to set the authority header by the sender of notifications. See https://tools.ietf.org/html/rfc7540#section-8.1.2.3 + + * `resend_interval`: A Duration represents a fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". Range is approximately 10,000 years. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + + * `nanos`: Span of time that's a fraction of a second at nanosecond resolution. Durations less than one second are represented with a 0 `seconds` field and a positive `nanos` field. Must be from 0 to 999,999,999 inclusive. + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_region_notification_endpoints.md b/docs/resources/google_compute_region_notification_endpoints.md new file mode 100644 index 000000000..3af9bbd5b --- /dev/null +++ b/docs/resources/google_compute_region_notification_endpoints.md @@ -0,0 +1,35 @@ +--- +title: About the google_compute_region_notification_endpoints resource +platform: gcp +--- + +## Syntax +A `google_compute_region_notification_endpoints` is used to test a Google RegionNotificationEndpoint resource + +## Examples +``` + describe google_compute_region_notification_endpoints(project: 'chef-gcp-inspec', region: ' value_region') do + it { should exist } + end +``` + +## Properties +Properties that can be accessed from the `google_compute_region_notification_endpoints` resource: + +See [google_compute_region_notification_endpoint.md](google_compute_region_notification_endpoint.md) for more detailed information + * `kinds`: an array of `google_compute_region_notification_endpoint` kind + * `ids`: an array of `google_compute_region_notification_endpoint` id + * `creation_timestamps`: an array of `google_compute_region_notification_endpoint` creation_timestamp + * `names`: an array of `google_compute_region_notification_endpoint` name + * `descriptions`: an array of `google_compute_region_notification_endpoint` description + * `self_links`: an array of `google_compute_region_notification_endpoint` self_link + * `regions`: an array of `google_compute_region_notification_endpoint` region + * `grpc_settings`: an array of `google_compute_region_notification_endpoint` grpc_settings + +## 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 [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/compute/property/regionnotificationendpoint_grpc_settings.rb b/libraries/google/compute/property/regionnotificationendpoint_grpc_settings.rb new file mode 100644 index 000000000..aaa94cab5 --- /dev/null +++ b/libraries/google/compute/property/regionnotificationendpoint_grpc_settings.rb @@ -0,0 +1,47 @@ +# 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 'google/compute/property/regionnotificationendpoint_grpc_settings_resend_interval' +module GoogleInSpec + module Compute + module Property + class RegionNotificationEndpointGrpcSettings + attr_reader :endpoint + + attr_reader :retry_duration_sec + + attr_reader :payload_name + + attr_reader :authority + + attr_reader :resend_interval + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @endpoint = args['endpoint'] + @retry_duration_sec = args['retryDurationSec'] + @payload_name = args['payloadName'] + @authority = args['authority'] + @resend_interval = GoogleInSpec::Compute::Property::RegionNotificationEndpointGrpcSettingsResendInterval.new(args['resendInterval'], to_s) + end + + def to_s + "#{@parent_identifier} RegionNotificationEndpointGrpcSettings" + end + end + end + end +end diff --git a/libraries/google/compute/property/regionnotificationendpoint_grpc_settings_resend_interval.rb b/libraries/google/compute/property/regionnotificationendpoint_grpc_settings_resend_interval.rb new file mode 100644 index 000000000..13bb74af2 --- /dev/null +++ b/libraries/google/compute/property/regionnotificationendpoint_grpc_settings_resend_interval.rb @@ -0,0 +1,37 @@ +# 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 RegionNotificationEndpointGrpcSettingsResendInterval + attr_reader :seconds + + attr_reader :nanos + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @seconds = args['seconds'] + @nanos = args['nanos'] + end + + def to_s + "#{@parent_identifier} RegionNotificationEndpointGrpcSettingsResendInterval" + end + end + end + end +end diff --git a/libraries/google_compute_region_notification_endpoint.rb b/libraries/google_compute_region_notification_endpoint.rb new file mode 100644 index 000000000..95dbe43c7 --- /dev/null +++ b/libraries/google_compute_region_notification_endpoint.rb @@ -0,0 +1,71 @@ +# 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' +require 'google/compute/property/regionnotificationendpoint_grpc_settings' +require 'google/compute/property/regionnotificationendpoint_grpc_settings_resend_interval' + +# A provider to manage Compute Engine resources. +class ComputeRegionNotificationEndpoint < GcpResourceBase + name 'google_compute_region_notification_endpoint' + desc 'RegionNotificationEndpoint' + supports platform: 'gcp' + + attr_reader :params + 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 :grpc_settings + + 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 + @kind = @fetched['kind'] + @id = @fetched['id'] + @creation_timestamp = @fetched['creationTimestamp'] + @name = @fetched['name'] + @description = @fetched['description'] + @self_link = @fetched['selfLink'] + @region = @fetched['region'] + @grpc_settings = GoogleInSpec::Compute::Property::RegionNotificationEndpointGrpcSettings.new(@fetched['grpcSettings'], to_s) + end + + def exists? + !@fetched.nil? + end + + def to_s + "RegionNotificationEndpoint #{@params[:notificationEndpoint]}" + end + + private + + def product_url(_ = nil) + 'https://compute.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/notificationEndpoints/{{notification_endpoint}}' + end +end diff --git a/libraries/google_compute_region_notification_endpoints.rb b/libraries/google_compute_region_notification_endpoints.rb new file mode 100644 index 000000000..425463c16 --- /dev/null +++ b/libraries/google_compute_region_notification_endpoints.rb @@ -0,0 +1,93 @@ +# 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 ComputeRegionNotificationEndpoints < GcpResourceBase + name 'google_compute_region_notification_endpoints' + desc 'RegionNotificationEndpoint plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + 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(:grpc_settings, field: :grpc_settings) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('regionNotificationEndpoints') + 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 + { + 'kind' => ->(obj) { [:kind, obj['kind']] }, + 'id' => ->(obj) { [:id, obj['id']] }, + 'creationTimestamp' => ->(obj) { [:creation_timestamp, obj['creationTimestamp']] }, + 'name' => ->(obj) { [:name, obj['name']] }, + 'description' => ->(obj) { [:description, obj['description']] }, + 'selfLink' => ->(obj) { [:self_link, obj['selfLink']] }, + 'region' => ->(obj) { [:region, obj['region']] }, + 'grpcSettings' => ->(obj) { [:grpc_settings, GoogleInSpec::Compute::Property::RegionNotificationEndpointGrpcSettings.new(obj['grpcSettings'], to_s)] }, + } + end + + private + + def product_url(_ = nil) + 'https://compute.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/notificationEndpoints' + end +end diff --git a/test/integration/verify/controls/google_compute_region_notification_endpoint.rb b/test/integration/verify/controls/google_compute_region_notification_endpoint.rb new file mode 100644 index 000000000..edfc27750 --- /dev/null +++ b/test/integration/verify/controls/google_compute_region_notification_endpoint.rb @@ -0,0 +1,49 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_compute_region_notification_endpoint resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + region_notification_endpoint = input('region_notification_endpoint', value: { + "project": "value_project", + "public_advertised_prefix": "value_publicadvertisedprefix", + "kind": "value_kind", + "id": "value_id", + "creation_timestamp": "value_creationtimestamp", + "name": "value_name", + "description": "value_description", + "self_link": "value_selflink", + "region": "value_region" +}, description: 'region_notification_endpoint description') +control 'google_compute_region_notification_endpoint-1.0' do + impact 1.0 + title 'google_compute_region_notification_endpoint resource test' + + describe google_compute_region_notification_endpoint(notificationEndpoint: region_notification_endpoint['notificationEndpoint'], project: gcp_project_id, region: region_notification_endpoint['region']) do + it { should exist } + its('kind') { should cmp region_notification_endpoint['kind'] } + its('id') { should cmp region_notification_endpoint['id'] } + its('creation_timestamp') { should cmp region_notification_endpoint['creation_timestamp'] } + its('name') { should cmp region_notification_endpoint['name'] } + its('description') { should cmp region_notification_endpoint['description'] } + its('self_link') { should cmp region_notification_endpoint['self_link'] } + its('region') { should cmp region_notification_endpoint['region'] } + + end + + describe google_compute_region_notification_endpoint(notificationEndpoint: region_notification_endpoint['notificationEndpoint'], project: gcp_project_id, region: region_notification_endpoint['region']) do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_compute_region_notification_endpoints.rb b/test/integration/verify/controls/google_compute_region_notification_endpoints.rb new file mode 100644 index 000000000..8206d863e --- /dev/null +++ b/test/integration/verify/controls/google_compute_region_notification_endpoints.rb @@ -0,0 +1,37 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_compute_region_notification_endpoints resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + region_notification_endpoint = input('region_notification_endpoint', value: { + "project": "value_project", + "public_advertised_prefix": "value_publicadvertisedprefix", + "kind": "value_kind", + "id": "value_id", + "creation_timestamp": "value_creationtimestamp", + "name": "value_name", + "description": "value_description", + "self_link": "value_selflink", + "region": "value_region" +}, description: 'region_notification_endpoint description') +control 'google_compute_region_notification_endpoints-1.0' do + impact 1.0 + title 'google_compute_region_notification_endpoints resource test' + + describe google_compute_region_notification_endpoints(project: gcp_project_id, region: region_notification_endpoint['region']) do + it { should exist } + end +end