From d22e04178f20c6832dc8f1d15c39640ffce0f32f Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 1 Nov 2019 23:29:43 +0000 Subject: [PATCH 01/19] Add InSpec support for cloud scheduler job Signed-off-by: Modular Magician --- docs/resources/google_cloud_scheduler_job.md | 97 +++++++++++++++++ docs/resources/google_cloud_scheduler_jobs.md | 42 ++++++++ .../property/job_app_engine_http_target.rb | 47 ++++++++ ...p_engine_http_target_app_engine_routing.rb | 40 +++++++ .../property/job_http_target.rb | 51 +++++++++ .../property/job_http_target_oauth_token.rb | 37 +++++++ .../property/job_http_target_oidc_token.rb | 37 +++++++ .../property/job_pubsub_target.rb | 40 +++++++ .../property/job_retry_config.rb | 46 ++++++++ libraries/google_cloud_scheduler_job.rb | 83 +++++++++++++++ libraries/google_cloud_scheduler_jobs.rb | 100 ++++++++++++++++++ test/integration/build/gcp-mm.tf | 18 ++++ .../configuration/mm-attributes.yml | 10 ++ .../controls/google_cloud_scheduler_job.rb | 40 +++++++ .../controls/google_cloud_scheduler_jobs.rb | 42 ++++++++ 15 files changed, 730 insertions(+) create mode 100644 docs/resources/google_cloud_scheduler_job.md create mode 100644 docs/resources/google_cloud_scheduler_jobs.md create mode 100644 libraries/google/cloudscheduler/property/job_app_engine_http_target.rb create mode 100644 libraries/google/cloudscheduler/property/job_app_engine_http_target_app_engine_routing.rb create mode 100644 libraries/google/cloudscheduler/property/job_http_target.rb create mode 100644 libraries/google/cloudscheduler/property/job_http_target_oauth_token.rb create mode 100644 libraries/google/cloudscheduler/property/job_http_target_oidc_token.rb create mode 100644 libraries/google/cloudscheduler/property/job_pubsub_target.rb create mode 100644 libraries/google/cloudscheduler/property/job_retry_config.rb create mode 100644 libraries/google_cloud_scheduler_job.rb create mode 100644 libraries/google_cloud_scheduler_jobs.rb create mode 100644 test/integration/verify/controls/google_cloud_scheduler_job.rb create mode 100644 test/integration/verify/controls/google_cloud_scheduler_jobs.rb diff --git a/docs/resources/google_cloud_scheduler_job.md b/docs/resources/google_cloud_scheduler_job.md new file mode 100644 index 000000000..7fc253b13 --- /dev/null +++ b/docs/resources/google_cloud_scheduler_job.md @@ -0,0 +1,97 @@ +--- +title: About the google_cloud_scheduler_job resource +platform: gcp +--- + +## Syntax +A `google_cloud_scheduler_job` is used to test a Google Job resource + +## Examples +``` +describe google_cloud_scheduler_job(project: 'chef-gcp-inspec', region: us-central1, name: 'job-name') do + it { should exist } + + its('description') { should cmp 'A description' } + its('schedule') { should cmp '*/8 * * * *' } + its('time_zone') { should cmp 'America/New_York' } + its('http_target.http_method') { should cmp 'POST' } + its('http_target.uri') { should cmp 'https://example.com/ping' } +end +``` + +## Properties +Properties that can be accessed from the `google_cloud_scheduler_job` resource: + + + * `name`: The name of the job. + + * `description`: A human-readable description for the job. This string must not contain more than 500 characters. + + * `schedule`: Describes the schedule on which the job will be executed. + + * `time_zone`: Specifies the time zone to be used in interpreting schedule. The value of this field must be a time zone name from the tz database. + + * `retry_config`: By default, if a job does not complete successfully, meaning that an acknowledgement is not received from the handler, then it will be retried with exponential backoff according to the settings + + * `retry_count`: The number of attempts that the system will make to run a job using the exponential backoff procedure described by maxDoublings. Values greater than 5 and negative values are not allowed. + + * `max_retry_duration`: The time limit for retrying a failed job, measured from time when an execution was first attempted. If specified with retryCount, the job will be retried until both limits are reached. A duration in seconds with up to nine fractional digits, terminated by 's'. + + * `min_backoff_duration`: The minimum amount of time to wait before retrying a job after it fails. A duration in seconds with up to nine fractional digits, terminated by 's'. + + * `max_backoff_duration`: The maximum amount of time to wait before retrying a job after it fails. A duration in seconds with up to nine fractional digits, terminated by 's'. + + * `max_doublings`: The time between retries will double maxDoublings times. A job's retry interval starts at minBackoffDuration, then doubles maxDoublings times, then increases linearly, and finally retries retries at intervals of maxBackoffDuration up to retryCount times. + + * `pubsub_target`: Pub/Sub target If the job providers a Pub/Sub target the cron will publish a message to the provided topic + + * `topic_name`: The name of the Cloud Pub/Sub topic to which messages will be published when a job is delivered. The topic name must be in the same format as required by PubSub's PublishRequest.name, for example projects/PROJECT_ID/topics/TOPIC_ID. + + * `data`: The message payload for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute. + + * `attributes`: Attributes for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute. + + * `app_engine_http_target`: App Engine HTTP target. If the job providers a App Engine HTTP target the cron will send a request to the service instance + + * `http_method`: Which HTTP method to use for the request. + + * `app_engine_routing`: App Engine Routing setting for the job. + + * `service`: App service. By default, the job is sent to the service which is the default service when the job is attempted. + + * `version`: App version. By default, the job is sent to the version which is the default version when the job is attempted. + + * `instance`: App instance. By default, the job is sent to an instance which is available when the job is attempted. + + * `relative_uri`: The relative URI. The relative URL must begin with "/" and must be a valid HTTP relative URL. It can contain a path, query string arguments, and \# fragments. If the relative URL is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters + + * `body`: HTTP request body. A request body is allowed only if the HTTP method is POST or PUT. It will result in invalid argument error to set a body on a job with an incompatible HttpMethod. + + * `headers`: HTTP request headers. This map contains the header field names and values. Headers can be set when the job is created. + + * `http_target`: HTTP target. If the job providers a http_target the cron will send a request to the targeted url + + * `uri`: The full URI path that the request will be sent to. + + * `http_method`: Which HTTP method to use for the request. + + * `body`: HTTP request body. A request body is allowed only if the HTTP method is POST, PUT, or PATCH. It is an error to set body on a job with an incompatible HttpMethod. + + * `headers`: This map contains the header field names and values. Repeated headers are not supported, but a header value can contain commas. + + * `oauth_token`: Contains information needed for generating an OAuth token. This type of authorization should be used when sending requests to a GCP endpoint. + + * `service_account_email`: Service account email to be used for generating OAuth token. The service account must be within the same project as the job. + + * `scope`: OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used. + + * `oidc_token`: Contains information needed for generating an OpenID Connect token. This type of authorization should be used when sending requests to third party endpoints or Cloud Run. + + * `service_account_email`: Service account email to be used for generating OAuth token. The service account must be within the same project as the job. + + * `audience`: Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used. + + * `region`: Region where the scheduler job resides + + +## GCP Permissions diff --git a/docs/resources/google_cloud_scheduler_jobs.md b/docs/resources/google_cloud_scheduler_jobs.md new file mode 100644 index 000000000..d420a6a3c --- /dev/null +++ b/docs/resources/google_cloud_scheduler_jobs.md @@ -0,0 +1,42 @@ +--- +title: About the google_cloud_scheduler_jobs resource +platform: gcp +--- + +## Syntax +A `google_cloud_scheduler_jobs` is used to test a Google Job resource + +## Examples +``` +google_cloud_scheduler_jobs(project: 'chef-gcp-inspec', region: ).names.each do |name| + describe google_cloud_scheduler_job(project: 'chef-gcp-inspec', region: us-central1, name: name) do + it { should exist } + + its('description') { should cmp 'A description' } + its('schedule') { should cmp '*/8 * * * *' } + its('time_zone') { should cmp 'America/New_York' } + its('http_target.http_method') { should cmp 'POST' } + its('http_target.uri') { should cmp 'https://example.com/ping' } + end +end +``` + +## Properties +Properties that can be accessed from the `google_cloud_scheduler_jobs` resource: + +See [google_cloud_scheduler_job.md](google_cloud_scheduler_job.md) for more detailed information + * `names`: an array of `google_cloud_scheduler_job` name + * `descriptions`: an array of `google_cloud_scheduler_job` description + * `schedules`: an array of `google_cloud_scheduler_job` schedule + * `time_zones`: an array of `google_cloud_scheduler_job` time_zone + * `retry_configs`: an array of `google_cloud_scheduler_job` retry_config + * `pubsub_targets`: an array of `google_cloud_scheduler_job` pubsub_target + * `app_engine_http_targets`: an array of `google_cloud_scheduler_job` app_engine_http_target + * `http_targets`: an array of `google_cloud_scheduler_job` http_target + * `regions`: an array of `google_cloud_scheduler_job` region + +## 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 diff --git a/libraries/google/cloudscheduler/property/job_app_engine_http_target.rb b/libraries/google/cloudscheduler/property/job_app_engine_http_target.rb new file mode 100644 index 000000000..baaf75d9a --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_app_engine_http_target.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/cloudscheduler/property/job_app_engine_http_target_app_engine_routing' +module GoogleInSpec + module CloudScheduler + module Property + class JobAppEngineHttpTarget + attr_reader :http_method + + attr_reader :app_engine_routing + + attr_reader :relative_uri + + attr_reader :body + + attr_reader :headers + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @http_method = args['httpMethod'] + @app_engine_routing = GoogleInSpec::CloudScheduler::Property::JobAppEngineHttpTargetAppEngineRouting.new(args['appEngineRouting'], to_s) + @relative_uri = args['relativeUri'] + @body = args['body'] + @headers = args['headers'] + end + + def to_s + "#{@parent_identifier} JobAppEngineHttpTarget" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_app_engine_http_target_app_engine_routing.rb b/libraries/google/cloudscheduler/property/job_app_engine_http_target_app_engine_routing.rb new file mode 100644 index 000000000..68774b39a --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_app_engine_http_target_app_engine_routing.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudScheduler + module Property + class JobAppEngineHttpTargetAppEngineRouting + attr_reader :service + + attr_reader :version + + attr_reader :instance + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @service = args['service'] + @version = args['version'] + @instance = args['instance'] + end + + def to_s + "#{@parent_identifier} JobAppEngineHttpTargetAppEngineRouting" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_http_target.rb b/libraries/google/cloudscheduler/property/job_http_target.rb new file mode 100644 index 000000000..1724dbf0c --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_http_target.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/cloudscheduler/property/job_http_target_oauth_token' +require 'google/cloudscheduler/property/job_http_target_oidc_token' +module GoogleInSpec + module CloudScheduler + module Property + class JobHttpTarget + attr_reader :uri + + attr_reader :http_method + + attr_reader :body + + attr_reader :headers + + attr_reader :oauth_token + + attr_reader :oidc_token + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @uri = args['uri'] + @http_method = args['httpMethod'] + @body = args['body'] + @headers = args['headers'] + @oauth_token = GoogleInSpec::CloudScheduler::Property::JobHttpTargetOauthToken.new(args['oauthToken'], to_s) + @oidc_token = GoogleInSpec::CloudScheduler::Property::JobHttpTargetOidcToken.new(args['oidcToken'], to_s) + end + + def to_s + "#{@parent_identifier} JobHttpTarget" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_http_target_oauth_token.rb b/libraries/google/cloudscheduler/property/job_http_target_oauth_token.rb new file mode 100644 index 000000000..69e5a45ea --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_http_target_oauth_token.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudScheduler + module Property + class JobHttpTargetOauthToken + attr_reader :service_account_email + + attr_reader :scope + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @service_account_email = args['serviceAccountEmail'] + @scope = args['scope'] + end + + def to_s + "#{@parent_identifier} JobHttpTargetOauthToken" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_http_target_oidc_token.rb b/libraries/google/cloudscheduler/property/job_http_target_oidc_token.rb new file mode 100644 index 000000000..551f768ef --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_http_target_oidc_token.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudScheduler + module Property + class JobHttpTargetOidcToken + attr_reader :service_account_email + + attr_reader :audience + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @service_account_email = args['serviceAccountEmail'] + @audience = args['audience'] + end + + def to_s + "#{@parent_identifier} JobHttpTargetOidcToken" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_pubsub_target.rb b/libraries/google/cloudscheduler/property/job_pubsub_target.rb new file mode 100644 index 000000000..0edd9bcb6 --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_pubsub_target.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudScheduler + module Property + class JobPubsubTarget + attr_reader :topic_name + + attr_reader :data + + attr_reader :attributes + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @topic_name = args['topicName'] + @data = args['data'] + @attributes = args['attributes'] + end + + def to_s + "#{@parent_identifier} JobPubsubTarget" + end + end + end + end +end diff --git a/libraries/google/cloudscheduler/property/job_retry_config.rb b/libraries/google/cloudscheduler/property/job_retry_config.rb new file mode 100644 index 000000000..64338beec --- /dev/null +++ b/libraries/google/cloudscheduler/property/job_retry_config.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudScheduler + module Property + class JobRetryConfig + attr_reader :retry_count + + attr_reader :max_retry_duration + + attr_reader :min_backoff_duration + + attr_reader :max_backoff_duration + + attr_reader :max_doublings + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @retry_count = args['retryCount'] + @max_retry_duration = args['maxRetryDuration'] + @min_backoff_duration = args['minBackoffDuration'] + @max_backoff_duration = args['maxBackoffDuration'] + @max_doublings = args['maxDoublings'] + end + + def to_s + "#{@parent_identifier} JobRetryConfig" + end + end + end + end +end diff --git a/libraries/google_cloud_scheduler_job.rb b/libraries/google_cloud_scheduler_job.rb new file mode 100644 index 000000000..710aff7bd --- /dev/null +++ b/libraries/google_cloud_scheduler_job.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/cloudscheduler/property/job_app_engine_http_target' +require 'google/cloudscheduler/property/job_app_engine_http_target_app_engine_routing' +require 'google/cloudscheduler/property/job_http_target' +require 'google/cloudscheduler/property/job_http_target_oauth_token' +require 'google/cloudscheduler/property/job_http_target_oidc_token' +require 'google/cloudscheduler/property/job_pubsub_target' +require 'google/cloudscheduler/property/job_retry_config' + +# A provider to manage Cloud Scheduler resources. +class CloudSchedulerJob < GcpResourceBase + name 'google_cloud_scheduler_job' + desc 'Job' + supports platform: 'gcp' + + attr_reader :params + attr_reader :name + attr_reader :description + attr_reader :schedule + attr_reader :time_zone + attr_reader :retry_config + attr_reader :pubsub_target + attr_reader :app_engine_http_target + attr_reader :http_target + attr_reader :region + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url, resource_base_url, params, 'Get') + parse unless @fetched.nil? + end + + def parse + @name = @fetched['name'] + @description = @fetched['description'] + @schedule = @fetched['schedule'] + @time_zone = @fetched['timeZone'] + @retry_config = GoogleInSpec::CloudScheduler::Property::JobRetryConfig.new(@fetched['retryConfig'], to_s) + @pubsub_target = GoogleInSpec::CloudScheduler::Property::JobPubsubTarget.new(@fetched['pubsubTarget'], to_s) + @app_engine_http_target = GoogleInSpec::CloudScheduler::Property::JobAppEngineHttpTarget.new(@fetched['appEngineHttpTarget'], to_s) + @http_target = GoogleInSpec::CloudScheduler::Property::JobHttpTarget.new(@fetched['httpTarget'], to_s) + @region = @fetched['region'] + end + + # Handles parsing RFC3339 time string + def parse_time_string(time_string) + time_string ? Time.parse(time_string) : nil + end + + def exists? + !@fetched.nil? + end + + def to_s + "Job #{@params[:name]}" + end + + private + + def product_url + 'https://cloudscheduler.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/locations/{{region}}/jobs/{{name}}' + end +end diff --git a/libraries/google_cloud_scheduler_jobs.rb b/libraries/google_cloud_scheduler_jobs.rb new file mode 100644 index 000000000..5d9e28946 --- /dev/null +++ b/libraries/google_cloud_scheduler_jobs.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 CloudSchedulerJobs < GcpResourceBase + name 'google_cloud_scheduler_jobs' + desc 'Job plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:names, field: :name) + filter_table_config.add(:descriptions, field: :description) + filter_table_config.add(:schedules, field: :schedule) + filter_table_config.add(:time_zones, field: :time_zone) + filter_table_config.add(:retry_configs, field: :retry_config) + filter_table_config.add(:pubsub_targets, field: :pubsub_target) + filter_table_config.add(:app_engine_http_targets, field: :app_engine_http_target) + filter_table_config.add(:http_targets, field: :http_target) + filter_table_config.add(:regions, field: :region) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('jobs') + 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) { return :name, obj['name'] }, + 'description' => ->(obj) { return :description, obj['description'] }, + 'schedule' => ->(obj) { return :schedule, obj['schedule'] }, + 'timeZone' => ->(obj) { return :time_zone, obj['timeZone'] }, + 'retryConfig' => ->(obj) { return :retry_config, GoogleInSpec::CloudScheduler::Property::JobRetryConfig.new(obj['retryConfig'], to_s) }, + 'pubsubTarget' => ->(obj) { return :pubsub_target, GoogleInSpec::CloudScheduler::Property::JobPubsubTarget.new(obj['pubsubTarget'], to_s) }, + 'appEngineHttpTarget' => ->(obj) { return :app_engine_http_target, GoogleInSpec::CloudScheduler::Property::JobAppEngineHttpTarget.new(obj['appEngineHttpTarget'], to_s) }, + 'httpTarget' => ->(obj) { return :http_target, GoogleInSpec::CloudScheduler::Property::JobHttpTarget.new(obj['httpTarget'], to_s) }, + 'region' => ->(obj) { return :region, obj['region'] }, + } + end + + # Handles parsing RFC3339 time string + def parse_time_string(time_string) + time_string ? Time.parse(time_string) : nil + end + + private + + def product_url + 'https://cloudscheduler.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/locations/{{region}}/jobs' + end +end diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 21678b63f..94b6f7219 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -209,6 +209,10 @@ variable "spannerdatabase" { type = "map" } +variable "scheduler_job" { + type = "map" +} + resource "google_compute_ssl_policy" "custom-ssl-policy" { name = "${var.ssl_policy["name"]}" @@ -893,3 +897,17 @@ resource "google_spanner_database" "database" { name = "${var.spannerdatabase["name"]}" ddl = ["${var.spannerdatabase["ddl"]}"] } + +resource "google_cloud_scheduler_job" "job" { + project = var.gcp_project_id + region = var.scheduler_job["region"] + name = var.scheduler_job["name"] + description = var.scheduler_job["description"] + schedule = var.scheduler_job["schedule"] + time_zone = var.scheduler_job["time_zone"] + + http_target { + http_method = var.scheduler_job["http_method"] + uri = var.scheduler_job["http_target_uri"] + } +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index f4ed2a05b..6f2ce5025 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -342,3 +342,13 @@ spannerdatabase: name: spdatabase instance: spinstance ddl: "CREATE TABLE test (test STRING(MAX),) PRIMARY KEY (test)" + +scheduler_job: + # region must match where the appengine instance is deployed + region: us-central1 + name: job-name + description: A description + schedule: "*/8 * * * *" + time_zone: America/New_York + http_method: POST + http_target_uri: https://example.com/ping diff --git a/test/integration/verify/controls/google_cloud_scheduler_job.rb b/test/integration/verify/controls/google_cloud_scheduler_job.rb new file mode 100644 index 000000000..9a26404a3 --- /dev/null +++ b/test/integration/verify/controls/google_cloud_scheduler_job.rb @@ -0,0 +1,40 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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_cloud_scheduler_job resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +scheduler_job = attribute('scheduler_job', default: { + "region": "us-central1", + "name": "job-name", + "description": "A description", + "schedule": "*/8 * * * *", + "time_zone": "America/New_York", + "http_method": "POST", + "http_target_uri": "https://example.com/ping" +}, description: 'Cloud Scheduler Job configuration') +control 'google_cloud_scheduler_job-1.0' do + impact 1.0 + title 'google_cloud_scheduler_job resource test' + + describe google_cloud_scheduler_job(project: gcp_project_id, region: scheduler_job['region'], name: scheduler_job['name']) do + it { should exist } + + its('description') { should cmp scheduler_job['description'] } + its('schedule') { should cmp scheduler_job['schedule'] } + its('time_zone') { should cmp scheduler_job['time_zone'] } + its('http_target.http_method') { should cmp scheduler_job['http_method'] } + its('http_target.uri') { should cmp scheduler_job['http_target_uri'] } + end +end diff --git a/test/integration/verify/controls/google_cloud_scheduler_jobs.rb b/test/integration/verify/controls/google_cloud_scheduler_jobs.rb new file mode 100644 index 000000000..12f7b540c --- /dev/null +++ b/test/integration/verify/controls/google_cloud_scheduler_jobs.rb @@ -0,0 +1,42 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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_cloud_scheduler_jobs resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +scheduler_job = attribute('scheduler_job', default: { + "region": "us-central1", + "name": "job-name", + "description": "A description", + "schedule": "*/8 * * * *", + "time_zone": "America/New_York", + "http_method": "POST", + "http_target_uri": "https://example.com/ping" +}, description: 'Cloud Scheduler Job configuration') +control 'google_cloud_scheduler_jobs-1.0' do + impact 1.0 + title 'google_cloud_scheduler_jobs resource test' + + google_cloud_scheduler_jobs(project: gcp_project_id, region: scheduler_job['location']).names.each do |name| + describe google_cloud_scheduler_job(project: gcp_project_id, region: scheduler_job['region'], name: name) do + it { should exist } + + its('description') { should cmp scheduler_job['description'] } + its('schedule') { should cmp scheduler_job['schedule'] } + its('time_zone') { should cmp scheduler_job['time_zone'] } + its('http_target.http_method') { should cmp scheduler_job['http_method'] } + its('http_target.uri') { should cmp scheduler_job['http_target_uri'] } + end + end +end From 04c0f74013da5df26f1c014091c61348a8bfe1b4 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 5 Nov 2019 13:51:06 -0800 Subject: [PATCH 02/19] Add L7 ILB fields to RegionBackendService (#244) Signed-off-by: Modular Magician --- .../google_compute_backend_service.md | 2 +- .../google_compute_region_backend_service.md | 44 ++++++++++++++----- .../google_compute_region_backend_services.md | 12 ++--- .../property/regionbackendservice_backends.rb | 27 ++++++++++++ .../google_compute_region_backend_service.rb | 24 +++++----- .../google_compute_region_backend_services.rb | 24 +++++----- 6 files changed, 96 insertions(+), 37 deletions(-) diff --git a/docs/resources/google_compute_backend_service.md b/docs/resources/google_compute_backend_service.md index 3babec57c..8a3350313 100644 --- a/docs/resources/google_compute_backend_service.md +++ b/docs/resources/google_compute_backend_service.md @@ -36,7 +36,7 @@ Properties that can be accessed from the `google_compute_backend_service` resour * `description`: An optional description of this resource. Provide this property when you create the resource. - * `group`: The fully-qualified URL of an Instance Group or Network Endpoint Group resource. In case of instance group this defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. For Network Endpoint Groups this defines list of endpoints. All endpoints of Network Endpoint Group must be hosted on instances located in the same zone as the Network Endpoint Group. Backend service can not contain mix of Instance Group and Network Endpoint Group backends. Note that you must specify an Instance Group or Network Endpoint Group resource using the fully-qualified URL, rather than a partial URL. + * `group`: The fully-qualified URL of an Instance Group or Network Endpoint Group resource. In case of instance group this defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. For Network Endpoint Groups this defines list of endpoints. All endpoints of Network Endpoint Group must be hosted on instances located in the same zone as the Network Endpoint Group. Backend services cannot mix Instance Group and Network Endpoint Group backends. Note that you must specify an Instance Group or Network Endpoint Group resource using the fully-qualified URL, rather than a partial URL. * `max_connections`: The max number of simultaneous connections for the group. Can be used with either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance or maxConnectionsPerEndpoint, as appropriate for group type, must be set. diff --git a/docs/resources/google_compute_region_backend_service.md b/docs/resources/google_compute_region_backend_service.md index ad5d5e92a..2269ed192 100644 --- a/docs/resources/google_compute_region_backend_service.md +++ b/docs/resources/google_compute_region_backend_service.md @@ -24,33 +24,55 @@ end Properties that can be accessed from the `google_compute_region_backend_service` resource: - * `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. + * `backends`: The set of backends that serve this RegionBackendService. - * `health_checks`: The list of HealthChecks for checking the health of the backend service. Currently at most one health check can be specified, and a health check is required. + * `balancing_mode`: Specifies the balancing mode for this backend. Defaults to CONNECTION. - * `backends`: The list of backends that serve this RegionBackendService. + * `capacity_scaler`: A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, RATE or CONNECTION). A setting of 0 means the group is completely drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. * `description`: An optional description of this resource. Provide this property when you create the resource. - * `group`: The fully-qualified URL of an Instance Group. This defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. Note that you must specify an Instance Group resource using the fully-qualified URL, rather than a partial URL. The instance group must be within the same region as the BackendService. + * `group`: The fully-qualified URL of an Instance Group or Network Endpoint Group resource. In case of instance group this defines the list of instances that serve traffic. Member virtual machine instances from each instance group must live in the same zone as the instance group itself. No two backends in a backend service are allowed to use same Instance Group resource. For Network Endpoint Groups this defines list of endpoints. All endpoints of Network Endpoint Group must be hosted on instances located in the same zone as the Network Endpoint Group. Backend services cannot mix Instance Group and Network Endpoint Group backends. When the `load_balancing_scheme` is INTERNAL, only instance groups are supported. Note that you must specify an Instance Group or Network Endpoint Group resource using the fully-qualified URL, rather than a partial URL. - * `description`: An optional description of this resource. + * `max_connections`: The max number of simultaneous connections for the group. Can be used with either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance or maxConnectionsPerEndpoint, as appropriate for group type, must be set. - * `fingerprint`: Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. + * `max_connections_per_instance`: The max number of simultaneous connections that a single backend instance can handle. This is used to calculate the capacity of the group. Can be used in either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be set. - * `protocol`: The protocol this BackendService uses to communicate with backends. The possible values are TCP and UDP, and the default is TCP. + * `max_connections_per_endpoint`: The max number of simultaneous connections that a single backend network endpoint can handle. This is used to calculate the capacity of the group. Can be used in either CONNECTION or UTILIZATION balancing modes. For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint must be set. - * `session_affinity`: Type of session affinity to use. The default is NONE. Can be NONE, CLIENT_IP, CLIENT_IP_PROTO, or CLIENT_IP_PORT_PROTO. When the protocol is UDP, this field is not used. + * `max_rate`: The max requests per second (RPS) of the group. Can be used with either RATE or UTILIZATION balancing modes, but required if RATE mode. Either maxRate or one of maxRatePerInstance or maxRatePerEndpoint, as appropriate for group type, must be set. - * `region`: The region where the regional backend service resides. + * `max_rate_per_instance`: The max requests per second (RPS) that a single backend instance can handle. This is used to calculate the capacity of the group. Can be used in either balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - * `timeout_sec`: How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. Valid range is [1, 86400]. + * `max_rate_per_endpoint`: The max requests per second (RPS) that a single backend network endpoint can handle. This is used to calculate the capacity of the group. Can be used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint must be set. + + * `max_utilization`: Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization target for the group. Valid range is [0.0, 1.0]. * `connection_draining`: Settings for connection draining * `draining_timeout_sec`: Time for which instance will be drained (not accept new connections, but still work to finish started). - * `load_balancing_scheme`: This signifies what the ForwardingRule will be used for and can only be INTERNAL for RegionBackendServices + * `creation_timestamp`: Creation timestamp in RFC3339 text format. + + * `description`: An optional description of this resource. + + * `fingerprint`: Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. + + * `health_checks`: The set of URLs to HealthCheck resources for health checking this RegionBackendService. Currently at most one health check can be specified, and a health check is required. + + * `id`: The unique identifier for the resource. + + * `load_balancing_scheme`: Indicates what kind of load balancing this regional backend service will be used for. A backend service created for one type of load balancing cannot be used with the other(s). Must be `INTERNAL` or `INTERNAL_MANAGED`. Defaults to `INTERNAL`. + + * `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. + + * `protocol`: The protocol this RegionBackendService uses to communicate with backends. Possible values are HTTP, HTTPS, HTTP2, SSL, TCP, and UDP. The default is HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors if used with the GA API. + + * `session_affinity`: Type of session affinity to use. The default is NONE. Session affinity is not applicable if the protocol is UDP. + + * `timeout_sec`: How many seconds to wait for the backend before considering it a failed request. Default is 30 seconds. Valid range is [1, 86400]. + + * `region`: A reference to the region where the regional backend service resides. ## GCP Permissions diff --git a/docs/resources/google_compute_region_backend_services.md b/docs/resources/google_compute_region_backend_services.md index ddb66832a..6e6a98fba 100644 --- a/docs/resources/google_compute_region_backend_services.md +++ b/docs/resources/google_compute_region_backend_services.md @@ -20,17 +20,19 @@ end Properties that can be accessed from the `google_compute_region_backend_services` resource: See [google_compute_region_backend_service.md](google_compute_region_backend_service.md) for more detailed information - * `names`: an array of `google_compute_region_backend_service` name - * `health_checks`: an array of `google_compute_region_backend_service` health_checks * `backends`: an array of `google_compute_region_backend_service` backends + * `connection_drainings`: an array of `google_compute_region_backend_service` connection_draining + * `creation_timestamps`: an array of `google_compute_region_backend_service` creation_timestamp * `descriptions`: an array of `google_compute_region_backend_service` description * `fingerprints`: an array of `google_compute_region_backend_service` fingerprint + * `health_checks`: an array of `google_compute_region_backend_service` health_checks + * `ids`: an array of `google_compute_region_backend_service` id + * `load_balancing_schemes`: an array of `google_compute_region_backend_service` load_balancing_scheme + * `names`: an array of `google_compute_region_backend_service` name * `protocols`: an array of `google_compute_region_backend_service` protocol * `session_affinities`: an array of `google_compute_region_backend_service` session_affinity - * `regions`: an array of `google_compute_region_backend_service` region * `timeout_secs`: an array of `google_compute_region_backend_service` timeout_sec - * `connection_drainings`: an array of `google_compute_region_backend_service` connection_draining - * `load_balancing_schemes`: an array of `google_compute_region_backend_service` load_balancing_scheme + * `regions`: an array of `google_compute_region_backend_service` region ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used diff --git a/libraries/google/compute/property/regionbackendservice_backends.rb b/libraries/google/compute/property/regionbackendservice_backends.rb index f45273875..13d14ef8f 100644 --- a/libraries/google/compute/property/regionbackendservice_backends.rb +++ b/libraries/google/compute/property/regionbackendservice_backends.rb @@ -17,15 +17,42 @@ module GoogleInSpec module Compute module Property class RegionBackendServiceBackends + attr_reader :balancing_mode + + attr_reader :capacity_scaler + attr_reader :description attr_reader :group + attr_reader :max_connections + + attr_reader :max_connections_per_instance + + attr_reader :max_connections_per_endpoint + + attr_reader :max_rate + + attr_reader :max_rate_per_instance + + attr_reader :max_rate_per_endpoint + + attr_reader :max_utilization + def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier + @balancing_mode = args['balancingMode'] + @capacity_scaler = args['capacityScaler'] @description = args['description'] @group = args['group'] + @max_connections = args['maxConnections'] + @max_connections_per_instance = args['maxConnectionsPerInstance'] + @max_connections_per_endpoint = args['maxConnectionsPerEndpoint'] + @max_rate = args['maxRate'] + @max_rate_per_instance = args['maxRatePerInstance'] + @max_rate_per_endpoint = args['maxRatePerEndpoint'] + @max_utilization = args['maxUtilization'] end def to_s diff --git a/libraries/google_compute_region_backend_service.rb b/libraries/google_compute_region_backend_service.rb index 7dc7b0b46..d1c355f35 100644 --- a/libraries/google_compute_region_backend_service.rb +++ b/libraries/google_compute_region_backend_service.rb @@ -24,17 +24,19 @@ class ComputeRegionBackendService < GcpResourceBase supports platform: 'gcp' attr_reader :params - attr_reader :name - attr_reader :health_checks attr_reader :backends + attr_reader :connection_draining + attr_reader :creation_timestamp attr_reader :description attr_reader :fingerprint + attr_reader :health_checks + attr_reader :id + attr_reader :load_balancing_scheme + attr_reader :name attr_reader :protocol attr_reader :session_affinity - attr_reader :region attr_reader :timeout_sec - attr_reader :connection_draining - attr_reader :load_balancing_scheme + attr_reader :region def initialize(params) super(params.merge({ use_http_transport: true })) @@ -44,17 +46,19 @@ def initialize(params) end def parse - @name = @fetched['name'] - @health_checks = @fetched['healthChecks'] @backends = GoogleInSpec::Compute::Property::RegionBackendServiceBackendsArray.parse(@fetched['backends'], to_s) + @connection_draining = GoogleInSpec::Compute::Property::RegionBackendServiceConnectionDraining.new(@fetched['connectionDraining'], to_s) + @creation_timestamp = parse_time_string(@fetched['creationTimestamp']) @description = @fetched['description'] @fingerprint = @fetched['fingerprint'] + @health_checks = @fetched['healthChecks'] + @id = @fetched['id'] + @load_balancing_scheme = @fetched['loadBalancingScheme'] + @name = @fetched['name'] @protocol = @fetched['protocol'] @session_affinity = @fetched['sessionAffinity'] - @region = @fetched['region'] @timeout_sec = @fetched['timeoutSec'] - @connection_draining = GoogleInSpec::Compute::Property::RegionBackendServiceConnectionDraining.new(@fetched['connectionDraining'], to_s) - @load_balancing_scheme = @fetched['loadBalancingScheme'] + @region = @fetched['region'] end # Handles parsing RFC3339 time string diff --git a/libraries/google_compute_region_backend_services.rb b/libraries/google_compute_region_backend_services.rb index 4afae5db4..5d0103c3a 100644 --- a/libraries/google_compute_region_backend_services.rb +++ b/libraries/google_compute_region_backend_services.rb @@ -23,17 +23,19 @@ class ComputeRegionBackendServices < GcpResourceBase filter_table_config = FilterTable.create - filter_table_config.add(:names, field: :name) - filter_table_config.add(:health_checks, field: :health_checks) filter_table_config.add(:backends, field: :backends) + filter_table_config.add(:connection_drainings, field: :connection_draining) + filter_table_config.add(:creation_timestamps, field: :creation_timestamp) filter_table_config.add(:descriptions, field: :description) filter_table_config.add(:fingerprints, field: :fingerprint) + filter_table_config.add(:health_checks, field: :health_checks) + filter_table_config.add(:ids, field: :id) + filter_table_config.add(:load_balancing_schemes, field: :load_balancing_scheme) + filter_table_config.add(:names, field: :name) filter_table_config.add(:protocols, field: :protocol) filter_table_config.add(:session_affinities, field: :session_affinity) - filter_table_config.add(:regions, field: :region) filter_table_config.add(:timeout_secs, field: :timeout_sec) - filter_table_config.add(:connection_drainings, field: :connection_draining) - filter_table_config.add(:load_balancing_schemes, field: :load_balancing_scheme) + filter_table_config.add(:regions, field: :region) filter_table_config.connect(self, :table) @@ -73,17 +75,19 @@ def transform(key, value) def transformers { - 'name' => ->(obj) { return :name, obj['name'] }, - 'healthChecks' => ->(obj) { return :health_checks, obj['healthChecks'] }, 'backends' => ->(obj) { return :backends, GoogleInSpec::Compute::Property::RegionBackendServiceBackendsArray.parse(obj['backends'], to_s) }, + 'connectionDraining' => ->(obj) { return :connection_draining, GoogleInSpec::Compute::Property::RegionBackendServiceConnectionDraining.new(obj['connectionDraining'], to_s) }, + 'creationTimestamp' => ->(obj) { return :creation_timestamp, parse_time_string(obj['creationTimestamp']) }, 'description' => ->(obj) { return :description, obj['description'] }, 'fingerprint' => ->(obj) { return :fingerprint, obj['fingerprint'] }, + 'healthChecks' => ->(obj) { return :health_checks, obj['healthChecks'] }, + 'id' => ->(obj) { return :id, obj['id'] }, + 'loadBalancingScheme' => ->(obj) { return :load_balancing_scheme, obj['loadBalancingScheme'] }, + 'name' => ->(obj) { return :name, obj['name'] }, 'protocol' => ->(obj) { return :protocol, obj['protocol'] }, 'sessionAffinity' => ->(obj) { return :session_affinity, obj['sessionAffinity'] }, - 'region' => ->(obj) { return :region, obj['region'] }, 'timeoutSec' => ->(obj) { return :timeout_sec, obj['timeoutSec'] }, - 'connectionDraining' => ->(obj) { return :connection_draining, GoogleInSpec::Compute::Property::RegionBackendServiceConnectionDraining.new(obj['connectionDraining'], to_s) }, - 'loadBalancingScheme' => ->(obj) { return :load_balancing_scheme, obj['loadBalancingScheme'] }, + 'region' => ->(obj) { return :region, obj['region'] }, } end From 5f54921cab9008ab1be6bb5becf73d6df4441a91 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 7 Nov 2019 18:36:21 +0000 Subject: [PATCH 03/19] [Ansible] Service Usage Services Signed-off-by: Modular Magician --- docs/resources/google_project_service.md | 16 ++++++- docs/resources/google_project_services.md | 2 + .../serviceusage/property/service_config.rb | 41 +++++++++++++++++ .../property/service_config_apis.rb | 45 +++++++++++++++++++ libraries/google_project_service.rb | 6 +++ libraries/google_project_services.rb | 4 ++ 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 libraries/google/serviceusage/property/service_config.rb create mode 100644 libraries/google/serviceusage/property/service_config_apis.rb diff --git a/docs/resources/google_project_service.md b/docs/resources/google_project_service.md index c538da757..99f05564e 100644 --- a/docs/resources/google_project_service.md +++ b/docs/resources/google_project_service.md @@ -20,10 +20,24 @@ Properties that can be accessed from the `google_project_service` resource: * `name`: The resource name of the service - * `parent`: The name of the parent of this service. For example: `projects/123` + * `parent`: The name of the parent of this service. For example 'projects/123' * `state`: Whether or not the service has been enabled for use by the consumer. + * `disable_dependent_services`: Indicates if dependent services should also be disabled. Can only be turned on if service is disabled. + + * `config`: The service configuration of the available service. + + * `name`: The DNS address at which this service is available. + + * `title`: The product title for this service + + * `apis`: The list of API interfaces exported by this service. + + * `name`: Name of the API + + * `version`: The version of the API + ## GCP Permissions diff --git a/docs/resources/google_project_services.md b/docs/resources/google_project_services.md index 986d43859..bffba8a86 100644 --- a/docs/resources/google_project_services.md +++ b/docs/resources/google_project_services.md @@ -24,6 +24,8 @@ See [google_project_service.md](google_project_service.md) for more detailed inf * `names`: an array of `google_project_service` name * `parents`: an array of `google_project_service` parent * `states`: an array of `google_project_service` state + * `disable_dependent_services`: an array of `google_project_service` disable_dependent_services + * `configs`: an array of `google_project_service` config ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used diff --git a/libraries/google/serviceusage/property/service_config.rb b/libraries/google/serviceusage/property/service_config.rb new file mode 100644 index 000000000..b1646b6ca --- /dev/null +++ b/libraries/google/serviceusage/property/service_config.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/serviceusage/property/service_config_apis' +module GoogleInSpec + module ServiceUsage + module Property + class ServiceConfig + attr_reader :name + + attr_reader :title + + attr_reader :apis + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @name = args['name'] + @title = args['title'] + @apis = GoogleInSpec::ServiceUsage::Property::ServiceConfigApisArray.parse(args['apis'], to_s) + end + + def to_s + "#{@parent_identifier} ServiceConfig" + end + end + end + end +end diff --git a/libraries/google/serviceusage/property/service_config_apis.rb b/libraries/google/serviceusage/property/service_config_apis.rb new file mode 100644 index 000000000..455356649 --- /dev/null +++ b/libraries/google/serviceusage/property/service_config_apis.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 ServiceUsage + module Property + class ServiceConfigApis + attr_reader :name + + attr_reader :version + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @name = args['name'] + @version = args['version'] + end + + def to_s + "#{@parent_identifier} ServiceConfigApis" + end + end + + class ServiceConfigApisArray + def self.parse(value, parent_identifier) + return if value.nil? + return ServiceConfigApis.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| ServiceConfigApis.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google_project_service.rb b/libraries/google_project_service.rb index 1ca048463..37fe4506d 100644 --- a/libraries/google_project_service.rb +++ b/libraries/google_project_service.rb @@ -14,6 +14,8 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' +require 'google/serviceusage/property/service_config' +require 'google/serviceusage/property/service_config_apis' # A provider to manage Service Usage resources. class ServiceUsageService < GcpResourceBase @@ -25,6 +27,8 @@ class ServiceUsageService < GcpResourceBase attr_reader :name attr_reader :parent attr_reader :state + attr_reader :disable_dependent_services + attr_reader :config def initialize(params) super(params.merge({ use_http_transport: true })) @@ -37,6 +41,8 @@ def parse @name = @fetched['name'] @parent = @fetched['parent'] @state = @fetched['state'] + @disable_dependent_services = @fetched['disableDependentServices'] + @config = GoogleInSpec::ServiceUsage::Property::ServiceConfig.new(@fetched['config'], to_s) end # Handles parsing RFC3339 time string diff --git a/libraries/google_project_services.rb b/libraries/google_project_services.rb index be604ed14..4d5071078 100644 --- a/libraries/google_project_services.rb +++ b/libraries/google_project_services.rb @@ -26,6 +26,8 @@ class ServiceUsageServices < GcpResourceBase filter_table_config.add(:names, field: :name) filter_table_config.add(:parents, field: :parent) filter_table_config.add(:states, field: :state) + filter_table_config.add(:disable_dependent_services, field: :disable_dependent_services) + filter_table_config.add(:configs, field: :config) filter_table_config.connect(self, :table) @@ -68,6 +70,8 @@ def transformers 'name' => ->(obj) { return :name, obj['name'] }, 'parent' => ->(obj) { return :parent, obj['parent'] }, 'state' => ->(obj) { return :state, obj['state'] }, + 'disableDependentServices' => ->(obj) { return :disable_dependent_services, obj['disableDependentServices'] }, + 'config' => ->(obj) { return :config, GoogleInSpec::ServiceUsage::Property::ServiceConfig.new(obj['config'], to_s) }, } end From 23ce238039ac35d6facb60453fe2da0f363df10a Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 13 Nov 2019 21:54:36 +0000 Subject: [PATCH 04/19] Inspec cloudbilling support Signed-off-by: Modular Magician --- .../google_billing_project_billing_info.md | 30 +++++++++ .../google_billing_project_billing_info.rb | 64 +++++++++++++++++++ .../google_billing_project_billing_info.rb | 30 +++++++++ 3 files changed, 124 insertions(+) create mode 100644 docs/resources/google_billing_project_billing_info.md create mode 100644 libraries/google_billing_project_billing_info.rb create mode 100644 test/integration/verify/controls/google_billing_project_billing_info.rb diff --git a/docs/resources/google_billing_project_billing_info.md b/docs/resources/google_billing_project_billing_info.md new file mode 100644 index 000000000..899963e3e --- /dev/null +++ b/docs/resources/google_billing_project_billing_info.md @@ -0,0 +1,30 @@ +--- +title: About the google_billing_project_billing_info resource +platform: gcp +--- + +## Syntax +A `google_billing_project_billing_info` is used to test a Google ProjectBillingInfo resource + +## Examples +``` +describe google_billing_project_billing_info(project_id: 'chef-gcp-inspec') do + it { should exist } + + its('billing_account_name') { should eq 'billingAccounts/012345-567890-ABCDEF'} + its('billing_enabled') { should eq true } +end +``` + +## Properties +Properties that can be accessed from the `google_billing_project_billing_info` resource: + + + * `project_id`: The project id to retrieve billing info for. + + * `billing_account_name`: The resource name of the billing account associated with the project, if any. For example, `billingAccounts/012345-567890-ABCDEF`. + + * `billing_enabled`: True if the project is associated with an open billing account, to which usage on the project is charged. False if the project is associated with a closed billing account, or no billing account at all, and therefore cannot use paid services. + + +## GCP Permissions diff --git a/libraries/google_billing_project_billing_info.rb b/libraries/google_billing_project_billing_info.rb new file mode 100644 index 000000000..d755b4608 --- /dev/null +++ b/libraries/google_billing_project_billing_info.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 Cloud Billing resources. +class BillingProjectBillingInfo < GcpResourceBase + name 'google_billing_project_billing_info' + desc 'ProjectBillingInfo' + supports platform: 'gcp' + + attr_reader :params + attr_reader :project_id + attr_reader :billing_account_name + attr_reader :billing_enabled + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url, resource_base_url, params, 'Get') + parse unless @fetched.nil? + end + + def parse + @project_id = @fetched['projectId'] + @billing_account_name = @fetched['billingAccountName'] + @billing_enabled = @fetched['billingEnabled'] + end + + # Handles parsing RFC3339 time string + def parse_time_string(time_string) + time_string ? Time.parse(time_string) : nil + end + + def exists? + !@fetched.nil? + end + + def to_s + "ProjectBillingInfo #{@params[:projectId]}" + end + + private + + def product_url + 'https://cloudbilling.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project_id}}/billingInfo' + end +end diff --git a/test/integration/verify/controls/google_billing_project_billing_info.rb b/test/integration/verify/controls/google_billing_project_billing_info.rb new file mode 100644 index 000000000..68ab69ddf --- /dev/null +++ b/test/integration/verify/controls/google_billing_project_billing_info.rb @@ -0,0 +1,30 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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_billing_project_billing_info resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') +control 'google_billing_project_billing_info-1.0' do + impact 1.0 + title 'google_billing_project_billing_info resource test' + + only_if { gcp_enable_privileged_resources.to_i == 1 && gcp_organization_id != ''} + describe google_billing_project_billing_info(project_id: gcp_project_id) do + it { should exist } + + its('billing_account_name') { should eq 'billingAccounts/012345-567890-ABCDEF'} + its('billing_enabled') { should eq true } + end +end From 06a2a2a12796f8f0d0dbedc76224995c82849162 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 13 Nov 2019 13:55:13 -0800 Subject: [PATCH 05/19] Minor documentation changes (#242) Signed-off-by: Modular Magician --- docs/resources/google_compute_backend_bucket.md | 2 +- docs/resources/google_pubsub_subscription.md | 2 +- test/integration/build/gcp-mm.tf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/google_compute_backend_bucket.md b/docs/resources/google_compute_backend_bucket.md index d00aa0658..78c4529bc 100644 --- a/docs/resources/google_compute_backend_bucket.md +++ b/docs/resources/google_compute_backend_bucket.md @@ -28,7 +28,7 @@ Properties that can be accessed from the `google_compute_backend_bucket` resourc * `cdn_policy`: Cloud CDN configuration for this Backend Bucket. - * `signed_url_cache_max_age_sec`: Maximum number of seconds the response to a signed URL request will be considered fresh. Defaults to 1hr (3600s). After this time period, the response will be revalidated before being served. When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered. + * `signed_url_cache_max_age_sec`: Maximum number of seconds the response to a signed URL request will be considered fresh. After this time period, the response will be revalidated before being served. When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered. * `creation_timestamp`: Creation timestamp in RFC3339 text format. diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index 9ef64038d..783017891 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -45,7 +45,7 @@ Properties that can be accessed from the `google_pubsub_subscription` resource: * `retain_acked_messages`: Indicates whether to retain acknowledged messages. If `true`, then messages are not expunged from the subscription's backlog, even if they are acknowledged, until they fall out of the messageRetentionDuration window. - * `expiration_policy`: A policy that specifies the conditions for this subscription's expiration. A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If expirationPolicy is not set, a default policy with ttl of 31 days will be used. If it is set but left empty, the resource never expires. The minimum allowed value for expirationPolicy.ttl is 1 day. + * `expiration_policy`: A policy that specifies the conditions for this subscription's expiration. A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If expirationPolicy is not set, a default policy with ttl of 31 days will be used. If it is set but ttl is "", the resource never expires. The minimum allowed value for expirationPolicy.ttl is 1 day. * `ttl`: Specifies the "time-to-live" duration for an associated resource. The resource expires if it is not active for a period of ttl. If ttl is not set, the associated resource never expires. A duration in seconds with up to nine fractional digits, terminated by 's'. Example - "3.5s". diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 94b6f7219..c150ab588 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -612,7 +612,7 @@ resource "google_cloudfunctions_function" "function" { trigger_http = "${var.cloudfunction["trigger_http"]}" timeout = "${var.cloudfunction["timeout"]}" entry_point = "${var.cloudfunction["entry_point"]}" - runtime = "nodejs6" + runtime = "nodejs8" environment_variables = { MY_ENV_VAR = "${var.cloudfunction["env_var_value"]}" From 14740dd3ab33047c1250619e16a66ed6f0a4a25a Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 20 Nov 2019 17:18:41 +0000 Subject: [PATCH 06/19] Billing info fix Signed-off-by: Modular Magician --- docs/resources/google_billing_project_billing_info.md | 2 +- .../verify/controls/google_billing_project_billing_info.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/resources/google_billing_project_billing_info.md b/docs/resources/google_billing_project_billing_info.md index 899963e3e..db13bbe8d 100644 --- a/docs/resources/google_billing_project_billing_info.md +++ b/docs/resources/google_billing_project_billing_info.md @@ -11,7 +11,7 @@ A `google_billing_project_billing_info` is used to test a Google ProjectBillingI describe google_billing_project_billing_info(project_id: 'chef-gcp-inspec') do it { should exist } - its('billing_account_name') { should eq 'billingAccounts/012345-567890-ABCDEF'} + its('billing_account_name') { should eq 'billingAccounts/012345-567890-ABCDEF' } its('billing_enabled') { should eq true } end ``` diff --git a/test/integration/verify/controls/google_billing_project_billing_info.rb b/test/integration/verify/controls/google_billing_project_billing_info.rb index 68ab69ddf..a9b685bb5 100644 --- a/test/integration/verify/controls/google_billing_project_billing_info.rb +++ b/test/integration/verify/controls/google_billing_project_billing_info.rb @@ -15,6 +15,8 @@ title 'Test GCP google_billing_project_billing_info resource.' gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +gcp_billing_account = attribute(:gcp_billing_account, default: 'gcp_billing_account', description: 'The GCP billing account name.') +gcp_organization_id = attribute(:gcp_organization_id, default: gcp_organization_id, description: 'The identifier of the organization') gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') control 'google_billing_project_billing_info-1.0' do impact 1.0 @@ -24,7 +26,7 @@ describe google_billing_project_billing_info(project_id: gcp_project_id) do it { should exist } - its('billing_account_name') { should eq 'billingAccounts/012345-567890-ABCDEF'} + its('billing_account_name') { should eq gcp_billing_account } its('billing_enabled') { should eq true } end end From 6ca227c0658953d205bfe54faf296d65251dd3bd Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Thu, 21 Nov 2019 23:51:45 +0000 Subject: [PATCH 07/19] Add cloudbuild_trigger build timeout and CustomizeDiff Signed-off-by: Modular Magician --- docs/resources/google_cloudbuild_trigger.md | 2 ++ libraries/google/cloudbuild/property/trigger_build.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/resources/google_cloudbuild_trigger.md b/docs/resources/google_cloudbuild_trigger.md index b0375dff1..8596b8c76 100644 --- a/docs/resources/google_cloudbuild_trigger.md +++ b/docs/resources/google_cloudbuild_trigger.md @@ -64,6 +64,8 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource: * `images`: A list of images to be pushed upon the successful completion of all build steps. The images are pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build status is marked FAILURE. + * `timeout`: Amount of time that this build should be allowed to run, to second granularity. If this amount of time elapses, work on the build will cease and the build status will be TIMEOUT. This timeout must be equal to or greater than the sum of the timeouts for build steps within the build. The expected format is the number of seconds followed by s. Default time is ten minutes (600s). + * `steps`: The operations to be performed on the workspace. * `name`: The name of the container image that will run this particular build step. If the image is available in the host's Docker daemon's cache, it will be run directly. If not, the host will attempt to pull the image first, using the builder service account's credentials if necessary. The Docker daemon's cache will already have the latest versions of all of the officially supported build steps (https://github.com/GoogleCloudPlatform/cloud-builders). The Docker daemon will also have cached many of the layers for some popular images, like "ubuntu", "debian", but they will be refreshed at the time you attempt to use them. If you built an image in a previous build step, it will be stored in the host's Docker daemon's cache and is available to use as the name for a later build step. diff --git a/libraries/google/cloudbuild/property/trigger_build.rb b/libraries/google/cloudbuild/property/trigger_build.rb index e8cefc39b..7400e811d 100644 --- a/libraries/google/cloudbuild/property/trigger_build.rb +++ b/libraries/google/cloudbuild/property/trigger_build.rb @@ -22,6 +22,8 @@ class TriggerBuild attr_reader :images + attr_reader :timeout + attr_reader :steps def initialize(args = nil, parent_identifier = nil) @@ -29,6 +31,7 @@ def initialize(args = nil, parent_identifier = nil) @parent_identifier = parent_identifier @tags = args['tags'] @images = args['images'] + @timeout = args['timeout'] @steps = GoogleInSpec::CloudBuild::Property::TriggerBuildStepsArray.parse(args['steps'], to_s) end From 597ae39dde150ad5aa2d9e5ff7b294c5499756df Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 2 Dec 2019 13:56:13 -0800 Subject: [PATCH 08/19] Add a kubernetes style resource async class (#253) Signed-off-by: Modular Magician --- docs/resources/google_redis_instance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/google_redis_instance.md b/docs/resources/google_redis_instance.md index 3d09b6084..08b8c9eca 100644 --- a/docs/resources/google_redis_instance.md +++ b/docs/resources/google_redis_instance.md @@ -46,7 +46,7 @@ Properties that can be accessed from the `google_redis_instance` resource: * `location_id`: The zone where the instance will be provisioned. If not provided, the service will choose a zone for the instance. For STANDARD_HA tier, instances will be created across two zones for protection against zonal failures. If [alternativeLocationId] is also provided, it must be different from [locationId]. - * `name`: The ID of the instance or a fully qualified identifier for the instance. + * `name`: The ID of the instance or a fully qualified identifier for the instance. * `memory_size_gb`: Redis memory size in GiB. From ce592cd98a602f8941efc7b2bef8eb21757558a4 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 3 Dec 2019 11:35:31 -0800 Subject: [PATCH 09/19] fix broken indent in bigquery dataset docs (#259) Signed-off-by: Modular Magician --- docs/resources/google_bigquery_dataset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/google_bigquery_dataset.md b/docs/resources/google_bigquery_dataset.md index e3cf5f402..6fd9d11db 100644 --- a/docs/resources/google_bigquery_dataset.md +++ b/docs/resources/google_bigquery_dataset.md @@ -44,7 +44,7 @@ Properties that can be accessed from the `google_bigquery_dataset` resource: * `role`: Describes the rights granted to the user specified by the other member of the access object. Primitive, Predefined and custom roles are supported. Predefined roles that have equivalent primitive roles are swapped by the API to their Primitive counterparts, and will show a diff post-create. See [official docs](https://cloud.google.com/bigquery/docs/access-control). - * `special_group`: A special group to grant access to. Possible values include: * `projectOwners`: Owners of the enclosing project. * `projectReaders`: Readers of the enclosing project. * `projectWriters`: Writers of the enclosing project. * `allAuthenticatedUsers`: All authenticated BigQuery users. + * `special_group`: A special group to grant access to. Possible values include: * `projectOwners`: Owners of the enclosing project. * `projectReaders`: Readers of the enclosing project. * `projectWriters`: Writers of the enclosing project. * `allAuthenticatedUsers`: All authenticated BigQuery users. * `user_by_email`: An email address of a user to grant access to. For example: fred@example.com From f967e3b3c6437c2468700418cd501c45cb81bde5 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 4 Dec 2019 18:19:04 +0000 Subject: [PATCH 10/19] Add support for spanner instance IAM to inspec Signed-off-by: Modular Magician --- .../google_spanner_instance_iam_policy.md | 46 +++++++++++++++ .../google_spanner_instance_iam_policy.rb | 59 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 docs/resources/google_spanner_instance_iam_policy.md create mode 100644 libraries/google_spanner_instance_iam_policy.rb diff --git a/docs/resources/google_spanner_instance_iam_policy.md b/docs/resources/google_spanner_instance_iam_policy.md new file mode 100644 index 000000000..9d457e54a --- /dev/null +++ b/docs/resources/google_spanner_instance_iam_policy.md @@ -0,0 +1,46 @@ +--- +title: About the google_spanner_instance_iam_policy resource +platform: gcp +--- + +## Syntax +A `google_spanner_instance_iam_policy` is used to test a Google Instance Iam Policy resource + +## Examples +``` +describe google_spanner_instance_iam_policy(project: "project", name: "name") do + it { should exist } +end + +google_spanner_instance_iam_policy(project: "project", name: "name").bindings.each do |binding| + describe binding do + its('role') { should eq 'roles/editor'} + its('members') { should include 'user:testuser@example.com'} + end +end +``` + +## Properties +Properties that can be accessed from the `google_spanner_instance_iam_policy` resource: + + * `bindings`: Associates a list of members to a role. + + * `role`: Role that is assigned to members. For example, roles/viewer, roles/editor, or roles/owner. + + * `members`: Specifies the identities requesting access for a Cloud Platform resource. + + * `audit_configs`: Specifies cloud audit logging configuration for this policy. + + * `service`: Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services. + + * `audit_log_configs`: The configuration for logging of each type of permission. + + * `log_type`: The log type that this config enables. For example, ADMIN_READ, DATA_WRITE or DATA_READ + + * `exempted_members`: Specifies the identities that do not cause logging for this type of permission. + + + +## GCP Permissions + +Ensure the [Cloud Spanner API](https://console.cloud.google.com/apis/library/spanner.googleapis.com/) is enabled for the current project. diff --git a/libraries/google_spanner_instance_iam_policy.rb b/libraries/google_spanner_instance_iam_policy.rb new file mode 100644 index 000000000..ae5980622 --- /dev/null +++ b/libraries/google_spanner_instance_iam_policy.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/iam/property/iam_policy_audit_configs' +require 'google/iam/property/iam_policy_bindings' + +# A provider to manage Cloud Spanner IAM Policy resources. +class InstanceIamPolicy < GcpResourceBase + name 'google_spanner_instance_iam_policy' + desc 'Instance Iam Policy' + supports platform: 'gcp' + + attr_reader :params + attr_reader :bindings + attr_reader :audit_configs + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url, resource_base_url, params, 'Post') + parse unless @fetched.nil? + end + + def parse + @bindings = GoogleInSpec::Iam::Property::IamPolicyBindingsArray.parse(@fetched['bindings'], to_s) + @audit_configs = GoogleInSpec::Iam::Property::IamPolicyAuditConfigsArray.parse(@fetched['auditConfigs'], to_s) + end + + def exists? + !@fetched.nil? + end + + def to_s + "Instance IamPolicy #{@params[:name]}" + end + + private + + def product_url + 'https://spanner.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/instances/{{name}}:getIamPolicy' + end +end From b1929ea02442e12822ab0615f1f27589b087ac37 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Thu, 5 Dec 2019 00:12:30 +0000 Subject: [PATCH 11/19] Add pubsubConfigs to cloud source repository Signed-off-by: Modular Magician --- .../google_sourcerepo_repositories.md | 1 + .../resources/google_sourcerepo_repository.md | 2 + .../property/repository_pubsub_configs.rb | 37 +++++++++++++++++++ libraries/google_sourcerepo_repositories.rb | 2 + libraries/google_sourcerepo_repository.rb | 3 ++ 5 files changed, 45 insertions(+) create mode 100644 libraries/google/sourcerepo/property/repository_pubsub_configs.rb diff --git a/docs/resources/google_sourcerepo_repositories.md b/docs/resources/google_sourcerepo_repositories.md index 31fb72978..9abea868e 100644 --- a/docs/resources/google_sourcerepo_repositories.md +++ b/docs/resources/google_sourcerepo_repositories.md @@ -25,6 +25,7 @@ See [google_sourcerepo_repository.md](google_sourcerepo_repository.md) for more * `names`: an array of `google_sourcerepo_repository` name * `urls`: an array of `google_sourcerepo_repository` url * `sizes`: an array of `google_sourcerepo_repository` size + * `pubsub_configs`: an array of `google_sourcerepo_repository` pubsub_configs ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used diff --git a/docs/resources/google_sourcerepo_repository.md b/docs/resources/google_sourcerepo_repository.md index 5f6a21aa0..8b034e223 100644 --- a/docs/resources/google_sourcerepo_repository.md +++ b/docs/resources/google_sourcerepo_repository.md @@ -27,6 +27,8 @@ Properties that can be accessed from the `google_sourcerepo_repository` resource * `size`: The disk usage of the repo, in bytes. + * `pubsub_configs`: How this repository publishes a change in the repository through Cloud Pub/Sub. Keyed by the topic names. + ## GCP Permissions diff --git a/libraries/google/sourcerepo/property/repository_pubsub_configs.rb b/libraries/google/sourcerepo/property/repository_pubsub_configs.rb new file mode 100644 index 000000000..e4f94c9b2 --- /dev/null +++ b/libraries/google/sourcerepo/property/repository_pubsub_configs.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 SourceRepo + module Property + class RepositoryPubsubConfigs + attr_reader :message_format + + attr_reader :service_account_email + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @message_format = args['messageFormat'] + @service_account_email = args['serviceAccountEmail'] + end + + def to_s + "#{@parent_identifier} RepositoryPubsubConfigs" + end + end + end + end +end diff --git a/libraries/google_sourcerepo_repositories.rb b/libraries/google_sourcerepo_repositories.rb index 704c6c46a..e589c80e2 100644 --- a/libraries/google_sourcerepo_repositories.rb +++ b/libraries/google_sourcerepo_repositories.rb @@ -26,6 +26,7 @@ class SourceRepoRepositorys < GcpResourceBase filter_table_config.add(:names, field: :name) filter_table_config.add(:urls, field: :url) filter_table_config.add(:sizes, field: :size) + filter_table_config.add(:pubsub_configs, field: :pubsub_configs) filter_table_config.connect(self, :table) @@ -68,6 +69,7 @@ def transformers 'name' => ->(obj) { return :name, obj['name'] }, 'url' => ->(obj) { return :url, obj['url'] }, 'size' => ->(obj) { return :size, obj['size'] }, + 'pubsubConfigs' => ->(obj) { return :pubsub_configs, obj['pubsubConfigs'] }, } end diff --git a/libraries/google_sourcerepo_repository.rb b/libraries/google_sourcerepo_repository.rb index 422477eb6..665d706df 100644 --- a/libraries/google_sourcerepo_repository.rb +++ b/libraries/google_sourcerepo_repository.rb @@ -14,6 +14,7 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' +require 'google/sourcerepo/property/repository_pubsub_configs' # A provider to manage Cloud Source Repositories resources. class SourceRepoRepository < GcpResourceBase @@ -25,6 +26,7 @@ class SourceRepoRepository < GcpResourceBase attr_reader :name attr_reader :url attr_reader :size + attr_reader :pubsub_configs def initialize(params) super(params.merge({ use_http_transport: true })) @@ -37,6 +39,7 @@ def parse @name = @fetched['name'] @url = @fetched['url'] @size = @fetched['size'] + @pubsub_configs = @fetched['pubsubConfigs'] end # Handles parsing RFC3339 time string From e3e78b941e3b181ee3dbd5047e236e1674dc9317 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 5 Dec 2019 10:48:11 -0800 Subject: [PATCH 12/19] correct documentation about multiple ssl certificates (#261) Signed-off-by: Modular Magician --- docs/resources/google_compute_target_https_proxy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/google_compute_target_https_proxy.md b/docs/resources/google_compute_target_https_proxy.md index 0b85b706e..59b8d8eed 100644 --- a/docs/resources/google_compute_target_https_proxy.md +++ b/docs/resources/google_compute_target_https_proxy.md @@ -33,7 +33,7 @@ Properties that can be accessed from the `google_compute_target_https_proxy` res * `quic_override`: Specifies the QUIC override policy for this resource. This determines whether the load balancer will attempt to negotiate QUIC with clients or not. Can specify one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with no user overrides, which is equivalent to DISABLE. Not specifying this field is equivalent to specifying NONE. - * `ssl_certificates`: A list of SslCertificate resources that are used to authenticate connections between users and the load balancer. Currently, exactly one SSL certificate must be specified. + * `ssl_certificates`: A list of SslCertificate resources that are used to authenticate connections between users and the load balancer. At least one SSL certificate must be specified. * `ssl_policy`: A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy resource. If not set, the TargetHttpsProxy resource will not have any SSL policy configured. From 8e8b7c0231b4dcc737825afe8e0e5d5e47b10dec Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 6 Dec 2019 12:32:16 -0800 Subject: [PATCH 13/19] Add route_rules to UrlMap for Traffic Director (#256) Signed-off-by: Modular Magician --- docs/resources/google_compute_url_map.md | 254 +++++++++++++++++- docs/resources/google_compute_url_maps.md | 3 +- .../compute/property/urlmap_header_action.rb | 45 ++++ ...ap_header_action_request_headers_to_add.rb | 48 ++++ ...p_header_action_response_headers_to_add.rb | 48 ++++ .../compute/property/urlmap_path_matchers.rb | 14 +- .../urlmap_path_matchers_header_action.rb | 45 ++++ ...rs_header_action_request_headers_to_add.rb | 48 ++++ ...s_header_action_response_headers_to_add.rb | 48 ++++ .../urlmap_path_matchers_route_rules.rb | 71 +++++ ...path_matchers_route_rules_header_action.rb | 45 ++++ ...es_header_action_request_headers_to_add.rb | 48 ++++ ...s_header_action_response_headers_to_add.rb | 48 ++++ ...p_path_matchers_route_rules_match_rules.rb | 63 +++++ ..._route_rules_match_rules_header_matches.rb | 64 +++++ ..._match_rules_header_matches_range_match.rb | 37 +++ ...oute_rules_match_rules_metadata_filters.rb | 46 ++++ ...ch_rules_metadata_filters_filter_labels.rb | 45 ++++ ...les_match_rules_query_parameter_matches.rb | 51 ++++ ..._path_matchers_route_rules_route_action.rb | 63 +++++ ...rs_route_rules_route_action_cors_policy.rb | 55 ++++ ...les_route_action_fault_injection_policy.rb | 40 +++ ...ute_action_fault_injection_policy_abort.rb | 37 +++ ...ute_action_fault_injection_policy_delay.rb | 38 +++ ...ault_injection_policy_delay_fixed_delay.rb | 37 +++ ...ules_route_action_request_mirror_policy.rb | 34 +++ ...s_route_rules_route_action_retry_policy.rb | 41 +++ ...ute_action_retry_policy_per_try_timeout.rb | 37 +++ ...tchers_route_rules_route_action_timeout.rb | 37 +++ ...rs_route_rules_route_action_url_rewrite.rb | 37 +++ ..._route_action_weighted_backend_services.rb | 51 ++++ ...weighted_backend_services_header_action.rb | 45 ++++ ...es_header_action_request_headers_to_add.rb | 48 ++++ ...s_header_action_response_headers_to_add.rb | 48 ++++ ..._path_matchers_route_rules_url_redirect.rb | 49 ++++ libraries/google_compute_url_map.rb | 9 +- libraries/google_compute_url_maps.rb | 6 +- 37 files changed, 1764 insertions(+), 19 deletions(-) create mode 100644 libraries/google/compute/property/urlmap_header_action.rb create mode 100644 libraries/google/compute/property/urlmap_header_action_request_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_header_action_response_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_header_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_header_action_request_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_request_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches_range_match.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters_filter_labels.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_query_parameter_matches.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_cors_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_route_rules_url_redirect.rb diff --git a/docs/resources/google_compute_url_map.md b/docs/resources/google_compute_url_map.md index b00cd0e1c..387475078 100644 --- a/docs/resources/google_compute_url_map.md +++ b/docs/resources/google_compute_url_map.md @@ -32,31 +32,51 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `creation_timestamp`: Creation timestamp in RFC3339 text format. - * `default_service`: A reference to BackendService resource if none of the hostRules match. + * `default_service`: The BackendService resource to which traffic is directed if none of the hostRules match. If defaultRouteAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of defaultService, defaultUrlRedirect or defaultRouteAction.weightedBackendService must be set. * `description`: An optional description of this resource. Provide this property when you create the resource. + * `id`: The unique identifier for the resource. + + * `fingerprint`: Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking. + + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. The headerAction specified here take effect after headerAction specified under pathMatcher. + + * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService. + + * `response_headers_to_add`: Headers to add the response prior to sending the response back to the client. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client. + * `host_rules`: The list of HostRules to use against the URL. - * `description`: An optional description of this HostRule. Provide this property when you create the resource. + * `description`: An optional description of this resource. Provide this property when you create the resource. * `hosts`: The list of host patterns to match. They must be valid hostnames, except * will match any string of ([a-z0-9-.]*). In that case, * must be the first character and must be followed in the pattern by either - or .. * `path_matcher`: The name of the PathMatcher to use to match the path portion of the URL if the hostRule matches the URL's host portion. - * `id`: The unique identifier for the resource. - - * `fingerprint`: Fingerprint of this resource. This field is used internally during updates of this resource. - * `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. * `path_matchers`: The list of named PathMatchers to use against the URL. - * `default_service`: A reference to a BackendService resource. This will be used if none of the pathRules defined by this PathMatcher is matched by the URL's path portion. - - * `description`: An optional description of this resource. + * `default_service`: The BackendService resource. This will be used if none of the pathRules or routeRules defined by this PathMatcher are matched. For example, the following are all valid URLs to a BackendService resource: - https://www.googleapis.com/compute/v1/projects/project/global/backendServices/backen dService - compute/v1/projects/project/global/backendServices/backendService - global/backendServices/backendService If defaultRouteAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if defaultService is specified, defaultRouteAction cannot contain any weightedBackendServices. Conversely, if defaultRouteAction specifies any weightedBackendServices, defaultService must not be specified. Only one of defaultService, defaultUrlRedirect or defaultRouteAction.weightedBackendService must be set. Authorization requires one or more of the following Google IAM permissions on the specified resource default_service: - compute.backendBuckets.use - compute.backendServices.use - * `name`: The name to which this PathMatcher is referred by the HostRule. + * `description`: An optional description of this resource. Provide this property when you create the resource. * `path_rules`: The list of path rules. @@ -64,7 +84,217 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `service`: A reference to the BackendService resource if this rule is matched. - * `tests`: The list of expected URL mappings. Requests to update this UrlMap will succeed only if all of the test cases pass. + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. HeaderAction specified here are applied after the matching HttpRouteRule HeaderAction and before the HeaderAction in the UrlMap + + * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService. + + * `response_headers_to_add`: Headers to add the response prior to sending the response back to the client. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client. + + * `name`: The name to which this PathMatcher is referred by the HostRule. + + * `route_rules`: The list of ordered HTTP route rules. Use this list instead of pathRules when advanced route matching and routing actions are desired. The order of specifying routeRules matters: the first rule that matches will cause its specified routing action to take effect. Within a given pathMatcher, only one of pathRules or routeRules must be set. routeRules are not supported in UrlMaps intended for External load balancers. + + * `priority`: For routeRules within a given pathMatcher, priority determines the order in which load balancer will interpret routeRules. RouteRules are evaluated in order of priority, from the lowest to highest number. The priority of a rule decreases as its number increases (1, 2, 3, N+1). The first rule that matches the request is applied. You cannot configure two or more routeRules with the same priority. Priority for each rule must be set to a number between 0 and 2147483647 inclusive. Priority numbers can have gaps, which enable you to add or remove rules in the future without affecting the rest of the rules. For example, 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future without any impact on existing rules. + + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. The headerAction specified here are applied before the matching pathMatchers[].headerAction and after pathMatchers[].routeRules[].r outeAction.weightedBackendService.backendServiceWeightAction[].headerAction + + * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService. + + * `response_headers_to_add`: Headers to add the response prior to sending the response back to the client. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client. + + * `match_rules`: The rules for determining a match. + + * `full_path_match`: For satifying the matchRule condition, the path of the request must exactly match the value specified in fullPathMatch after removing any query parameters and anchor that may be part of the original URL. FullPathMatch must be between 1 and 1024 characters. Only one of prefixMatch, fullPathMatch or regexMatch must be specified. + + * `header_matches`: Specifies a list of header match criteria, all of which must match corresponding headers in the request. + + * `exact_match`: The value should exactly match contents of exactMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `header_name`: The name of the HTTP header to match. For matching against the HTTP request's authority, use a headerMatch with the header name ":authority". For matching a request's method, use the headerName ":method". + + * `invert_match`: If set to false, the headerMatch is considered a match if the match criteria above are met. If set to true, the headerMatch is considered a match if the match criteria above are NOT met. Defaults to false. + + * `prefix_match`: The value of the header must start with the contents of prefixMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `present_match`: A header with the contents of headerName must exist. The match takes place whether or not the request's header has a value or not. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `range_match`: The header value must be an integer and its value must be in the range specified in rangeMatch. If the header does not contain an integer, number or is empty, the match fails. For example for a range [-5, 0] - -3 will match. - 0 will not match. - 0.25 will not match. - -3someString will not match. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `range_end`: The end of the range (exclusive). + + * `range_start`: The start of the range (inclusive). + + * `regex_match`: The value of the header must match the regualar expression specified in regexMatch. For regular expression grammar, please see: en.cppreference.com/w/cpp/regex/ecmascript For matching against a port specified in the HTTP request, use a headerMatch with headerName set to PORT and a regular expression that satisfies the RFC2616 Host header's port specifier. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `suffix_match`: The value of the header must end with the contents of suffixMatch. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch must be set. + + * `ignore_case`: Specifies that prefixMatch and fullPathMatch matches are case sensitive. Defaults to false. + + * `metadata_filters`: Opaque filter criteria used by Loadbalancer to restrict routing configuration to a limited set xDS compliant clients. In their xDS requests to Loadbalancer, xDS clients present node metadata. If a match takes place, the relevant routing configuration is made available to those proxies. For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, at least one of the filterLabels must match the corresponding label provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its filterLabels must match with corresponding labels in the provided metadata. metadataFilters specified here can be overrides those specified in ForwardingRule that refers to this UrlMap. metadataFilters only applies to Loadbalancers that have their loadBalancingScheme set to INTERNAL_SELF_MANAGED. + + * `filter_labels`: The list of label value pairs that must match labels in the provided metadata based on filterMatchCriteria This list must not be empty and can have at the most 64 entries. + + * `name`: Name of metadata label. The name can have a maximum length of 1024 characters and must be at least 1 character long. + + * `value`: The value of the label must match the specified value. value can have a maximum length of 1024 characters. + + * `filter_match_criteria`: Specifies how individual filterLabel matches within the list of filterLabels contribute towards the overall metadataFilter match. Supported values are: - MATCH_ANY: At least one of the filterLabels must have a matching label in the provided metadata. - MATCH_ALL: All filterLabels must have matching labels in the provided metadata. + + * `prefix_match`: For satifying the matchRule condition, the request's path must begin with the specified prefixMatch. prefixMatch must begin with a /. The value must be between 1 and 1024 characters. Only one of prefixMatch, fullPathMatch or regexMatch must be specified. + + * `query_parameter_matches`: Specifies a list of query parameter match criteria, all of which must match corresponding query parameters in the request. + + * `exact_match`: The queryParameterMatch matches if the value of the parameter exactly matches the contents of exactMatch. Only one of presentMatch, exactMatch and regexMatch must be set. + + * `name`: The name of the query parameter to match. The query parameter must exist in the request, in the absence of which the request match fails. + + * `present_match`: Specifies that the queryParameterMatch matches if the request contains the query parameter, irrespective of whether the parameter has a value or not. Only one of presentMatch, exactMatch and regexMatch must be set. + + * `regex_match`: The queryParameterMatch matches if the value of the parameter matches the regular expression specified by regexMatch. For the regular expression grammar, please see en.cppreference.com/w/cpp/regex/ecmascript Only one of presentMatch, exactMatch and regexMatch must be set. + + * `regex_match`: For satifying the matchRule condition, the path of the request must satisfy the regular expression specified in regexMatch after removing any query parameters and anchor supplied with the original URL. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript Only one of prefixMatch, fullPathMatch or regexMatch must be specified. + + * `route_action`: In response to a matching matchRule, the load balancer performs advanced routing actions like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend. If routeAction specifies any weightedBackendServices, service must not be set. Conversely if service is set, routeAction cannot contain any weightedBackendServices. Only one of routeAction or urlRedirect must be set. + + * `cors_policy`: The specification for allowing client side cross-origin requests. Please see W3C Recommendation for Cross Origin Resource Sharing + + * `allow_credentials`: In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This translates to the Access- Control-Allow-Credentials header. Defaults to false. + + * `allow_headers`: Specifies the content for the Access-Control-Allow-Headers header. + + * `allow_methods`: Specifies the content for the Access-Control-Allow-Methods header. + + * `allow_origin_regexes`: Specifies the regualar expression patterns that match allowed origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript An origin is allowed if it matches either allow_origins or allow_origin_regex. + + * `allow_origins`: Specifies the list of origins that will be allowed to do CORS requests. An origin is allowed if it matches either allow_origins or allow_origin_regex. + + * `disabled`: If true, specifies the CORS policy is disabled. which indicates that the CORS policy is in effect. Defaults to false. + + * `expose_headers`: Specifies the content for the Access-Control-Expose-Headers header. + + * `max_age`: Specifies how long the results of a preflight request can be cached. This translates to the content for the Access-Control-Max-Age header. + + * `fault_injection_policy`: The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced by Loadbalancer on a percentage of requests before sending those request to the backend service. Similarly requests from clients can be aborted by the Loadbalancer for a percentage of requests. timeout and retry_policy will be ignored by clients that are configured with a fault_injection_policy. + + * `abort`: The specification for how client requests are aborted as part of fault injection. + + * `http_status`: The HTTP status code used to abort the request. The value must be between 200 and 599 inclusive. + + * `percentage`: The percentage of traffic (connections/operations/requests) which will be aborted as part of fault injection. The value must be between 0.0 and 100.0 inclusive. + + * `delay`: The specification for how client requests are delayed as part of fault injection, before being sent to a backend service. + + * `fixed_delay`: Specifies the value of the fixed delay interval. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `percentage`: The percentage of traffic (connections/operations/requests) on which delay will be introduced as part of fault injection. The value must be between 0.0 and 100.0 inclusive. + + * `request_mirror_policy`: Specifies the policy on how requests intended for the route's backends are shadowed to a separate mirrored backend service. Loadbalancer does not wait for responses from the shadow service. Prior to sending traffic to the shadow service, the host / authority header is suffixed with -shadow. + + * `backend_service`: The BackendService resource being mirrored to. + + * `retry_policy`: Specifies the retry policy associated with this route. + + * `num_retries`: Specifies the allowed number retries. This number must be > 0. + + * `per_try_timeout`: Specifies a non-zero timeout per retry attempt. If not specified, will use the timeout set in HttpRouteAction. If timeout in HttpRouteAction is not set, will use the largest timeout among all backend services associated with the route. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `retry_conditions`: Specfies one or more conditions when this retry rule applies. Valid values are: - 5xx: Loadbalancer will attempt a retry if the backend service responds with any 5xx response code, or if the backend service does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: Loadbalancer will retry on failures connecting to backend services, for example due to connection timeouts. - retriable-4xx: Loadbalancer will retry for retriable 4xx response codes. Currently the only retriable error supported is 409. - refused-stream: Loadbalancer will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Loadbalancer will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Loadbalancer will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Loadbalancer will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Loadbalancer will retry if the gRPC status code in the response header is set to unavailable + + * `timeout`: Specifies the timeout for the selected route. Timeout is computed from the time the request is has been fully processed (i.e. end-of-stream) up until the response has been completely processed. Timeout includes all retries. If not specified, the default value is 15 seconds. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `url_rewrite`: The spec to modify the URL of the request, prior to forwarding the request to the matched service + + * `host_rewrite`: Prior to forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be between 1 and 255 characters. + + * `path_prefix_rewrite`: Prior to forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be between 1 and 1024 characters. + + * `weighted_backend_services`: A list of weighted backend services to send traffic to when a route match occurs. The weights determine the fraction of traffic that flows to their corresponding backend service. If all traffic needs to go to a single backend service, there must be one weightedBackendService with weight set to a non 0 number. Once a backendService is identified and before forwarding the request to the backend service, advanced routing actions like Url rewrites and header transformations are applied depending on additional settings specified in this HttpRouteAction. + + * `backend_service`: The default BackendService resource. Before forwarding the request to backendService, the loadbalancer applies any relevant headerActions specified as part of this backendServiceWeight. + + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. + + * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService. + + * `response_headers_to_add`: Headers to add the response prior to sending the response back to the client. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client. + + * `weight`: Specifies the fraction of traffic sent to backendService, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backendService, subsequent requests will be sent to the same backendService as determined by the BackendService's session affinity policy. The value must be between 0 and 1000 + + * `url_redirect`: When this rule is matched, the request is redirected to a URL specified by urlRedirect. If urlRedirect is specified, service or routeAction must not be set. + + * `host_redirect`: The host that will be used in the redirect response instead of the one that was supplied in the request. The value must be between 1 and 255 characters. + + * `https_redirect`: If set to true, the URL scheme in the redirected request is set to https. If set to false, the URL scheme of the redirected request will remain the same as that of the request. This must only be set for UrlMaps used in TargetHttpProxys. Setting this true for TargetHttpsProxy is not permitted. Defaults to false. + + * `path_redirect`: The path that will be used in the redirect response instead of the one that was supplied in the request. Only one of pathRedirect or prefixRedirect must be specified. The value must be between 1 and 1024 characters. + + * `prefix_redirect`: The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch, retaining the remaining portion of the URL before redirecting the request. + + * `redirect_response_code`: The HTTP Status code to use for this RedirectAction. Supported values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case, the request method will be retained. - PERMANENT_REDIRECT, which corresponds to 308. In this case, the request method will be retained. + + * `strip_query`: If set to true, any accompanying query portion of the original URL is removed prior to redirecting the request. If set to false, the query portion of the original URL is retained. Defaults to false. + + * `tests`: The list of expected URL mapping tests. Request to update this UrlMap will succeed only if all of the test cases pass. You can specify a maximum of 100 tests per UrlMap. * `description`: Description of this test case. @@ -72,7 +302,7 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `path`: Path portion of the URL. - * `service`: A reference to expected BackendService resource the given URL should be mapped to. + * `service`: Expected BackendService resource the given URL should be mapped to. ## GCP Permissions diff --git a/docs/resources/google_compute_url_maps.md b/docs/resources/google_compute_url_maps.md index 9f98d9c4f..a77dbdcdc 100644 --- a/docs/resources/google_compute_url_maps.md +++ b/docs/resources/google_compute_url_maps.md @@ -20,9 +20,10 @@ See [google_compute_url_map.md](google_compute_url_map.md) for more detailed inf * `creation_timestamps`: an array of `google_compute_url_map` creation_timestamp * `default_services`: an array of `google_compute_url_map` default_service * `descriptions`: an array of `google_compute_url_map` description - * `host_rules`: an array of `google_compute_url_map` host_rules * `ids`: an array of `google_compute_url_map` id * `fingerprints`: an array of `google_compute_url_map` fingerprint + * `header_actions`: an array of `google_compute_url_map` header_action + * `host_rules`: an array of `google_compute_url_map` host_rules * `names`: an array of `google_compute_url_map` name * `path_matchers`: an array of `google_compute_url_map` path_matchers * `tests`: an array of `google_compute_url_map` tests diff --git a/libraries/google/compute/property/urlmap_header_action.rb b/libraries/google/compute/property/urlmap_header_action.rb new file mode 100644 index 000000000..39393dbca --- /dev/null +++ b/libraries/google/compute/property/urlmap_header_action.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapHeaderAction + attr_reader :request_headers_to_add + + attr_reader :request_headers_to_remove + + attr_reader :response_headers_to_add + + attr_reader :response_headers_to_remove + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @request_headers_to_add = GoogleInSpec::Compute::Property::UrlMapHeaderActionRequestHeadersToAddArray.parse(args['requestHeadersToAdd'], to_s) + @request_headers_to_remove = args['requestHeadersToRemove'] + @response_headers_to_add = GoogleInSpec::Compute::Property::UrlMapHeaderActionResponseHeadersToAddArray.parse(args['responseHeadersToAdd'], to_s) + @response_headers_to_remove = args['responseHeadersToRemove'] + end + + def to_s + "#{@parent_identifier} UrlMapHeaderAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_header_action_request_headers_to_add.rb b/libraries/google/compute/property/urlmap_header_action_request_headers_to_add.rb new file mode 100644 index 000000000..491868a0f --- /dev/null +++ b/libraries/google/compute/property/urlmap_header_action_request_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapHeaderActionRequestHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapHeaderActionRequestHeadersToAdd" + end + end + + class UrlMapHeaderActionRequestHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapHeaderActionRequestHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapHeaderActionRequestHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_header_action_response_headers_to_add.rb b/libraries/google/compute/property/urlmap_header_action_response_headers_to_add.rb new file mode 100644 index 000000000..73ceb8a02 --- /dev/null +++ b/libraries/google/compute/property/urlmap_header_action_response_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapHeaderActionResponseHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapHeaderActionResponseHeadersToAdd" + end + end + + class UrlMapHeaderActionResponseHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapHeaderActionResponseHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapHeaderActionResponseHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers.rb b/libraries/google/compute/property/urlmap_path_matchers.rb index da8563514..a987f6cd4 100644 --- a/libraries/google/compute/property/urlmap_path_matchers.rb +++ b/libraries/google/compute/property/urlmap_path_matchers.rb @@ -13,7 +13,11 @@ # CONTRIBUTING.md located at the root of this package. # # ---------------------------------------------------------------------------- +require 'google/compute/property/urlmap_path_matchers_header_action' +require 'google/compute/property/urlmap_path_matchers_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add' require 'google/compute/property/urlmap_path_matchers_path_rules' +require 'google/compute/property/urlmap_path_matchers_route_rules' module GoogleInSpec module Compute module Property @@ -22,17 +26,23 @@ class UrlMapPathMatchers attr_reader :description + attr_reader :path_rules + + attr_reader :header_action + attr_reader :name - attr_reader :path_rules + attr_reader :route_rules def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier @default_service = args['defaultService'] @description = args['description'] - @name = args['name'] @path_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesArray.parse(args['pathRules'], to_s) + @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersHeaderAction.new(args['headerAction'], to_s) + @name = args['name'] + @route_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesArray.parse(args['routeRules'], to_s) end def to_s diff --git a/libraries/google/compute/property/urlmap_path_matchers_header_action.rb b/libraries/google/compute/property/urlmap_path_matchers_header_action.rb new file mode 100644 index 000000000..88c9a6b50 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_header_action.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersHeaderAction + attr_reader :request_headers_to_add + + attr_reader :request_headers_to_remove + + attr_reader :response_headers_to_add + + attr_reader :response_headers_to_remove + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @request_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersHeaderActionRequestHeadersToAddArray.parse(args['requestHeadersToAdd'], to_s) + @request_headers_to_remove = args['requestHeadersToRemove'] + @response_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersHeaderActionResponseHeadersToAddArray.parse(args['responseHeadersToAdd'], to_s) + @response_headers_to_remove = args['responseHeadersToRemove'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersHeaderAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_header_action_request_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_header_action_request_headers_to_add.rb new file mode 100644 index 000000000..d03feaf82 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_header_action_request_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersHeaderActionRequestHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersHeaderActionRequestHeadersToAdd" + end + end + + class UrlMapPathMatchersHeaderActionRequestHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersHeaderActionRequestHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersHeaderActionRequestHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add.rb new file mode 100644 index 000000000..4d0325474 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_header_action_response_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersHeaderActionResponseHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersHeaderActionResponseHeadersToAdd" + end + end + + class UrlMapPathMatchersHeaderActionResponseHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersHeaderActionResponseHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersHeaderActionResponseHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb new file mode 100644 index 000000000..faa6209d8 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_header_action' +require 'google/compute/property/urlmap_path_matchers_route_rules_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_route_rules_match_rules' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_cors_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services' +require 'google/compute/property/urlmap_path_matchers_route_rules_url_redirect' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRules + attr_reader :priority + + attr_reader :header_action + + attr_reader :match_rules + + attr_reader :route_action + + attr_reader :url_redirect + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @priority = args['priority'] + @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesHeaderAction.new(args['headerAction'], to_s) + @match_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesArray.parse(args['matchRules'], to_s) + @route_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteAction.new(args['routeAction'], to_s) + @url_redirect = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesUrlRedirect.new(args['urlRedirect'], to_s) + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRules" + end + end + + class UrlMapPathMatchersRouteRulesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRules.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRules.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action.rb new file mode 100644 index 000000000..5995e327a --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesHeaderAction + attr_reader :request_headers_to_add + + attr_reader :request_headers_to_remove + + attr_reader :response_headers_to_add + + attr_reader :response_headers_to_remove + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @request_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAddArray.parse(args['requestHeadersToAdd'], to_s) + @request_headers_to_remove = args['requestHeadersToRemove'] + @response_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAddArray.parse(args['responseHeadersToAdd'], to_s) + @response_headers_to_remove = args['responseHeadersToRemove'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesHeaderAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_request_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_request_headers_to_add.rb new file mode 100644 index 000000000..168c0d84f --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_request_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAdd" + end + end + + class UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesHeaderActionRequestHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add.rb new file mode 100644 index 000000000..21cc30fe8 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_header_action_response_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAdd" + end + end + + class UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesHeaderActionResponseHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules.rb new file mode 100644 index 000000000..04998391a --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_match_rules_header_matches' +require 'google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters' +require 'google/compute/property/urlmap_path_matchers_route_rules_match_rules_query_parameter_matches' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesMatchRules + attr_reader :full_path_match + + attr_reader :header_matches + + attr_reader :ignore_case + + attr_reader :metadata_filters + + attr_reader :prefix_match + + attr_reader :query_parameter_matches + + attr_reader :regex_match + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @full_path_match = args['fullPathMatch'] + @header_matches = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesHeaderMatchesArray.parse(args['headerMatches'], to_s) + @ignore_case = args['ignoreCase'] + @metadata_filters = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersArray.parse(args['metadataFilters'], to_s) + @prefix_match = args['prefixMatch'] + @query_parameter_matches = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatchesArray.parse(args['queryParameterMatches'], to_s) + @regex_match = args['regexMatch'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRules" + end + end + + class UrlMapPathMatchersRouteRulesMatchRulesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesMatchRules.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesMatchRules.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches.rb new file mode 100644 index 000000000..f5bb4ea9b --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_match_rules_header_matches_range_match' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesMatchRulesHeaderMatches + attr_reader :exact_match + + attr_reader :header_name + + attr_reader :invert_match + + attr_reader :prefix_match + + attr_reader :present_match + + attr_reader :range_match + + attr_reader :regex_match + + attr_reader :suffix_match + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @exact_match = args['exactMatch'] + @header_name = args['headerName'] + @invert_match = args['invertMatch'] + @prefix_match = args['prefixMatch'] + @present_match = args['presentMatch'] + @range_match = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesHeaderMatchesRangeMatch.new(args['rangeMatch'], to_s) + @regex_match = args['regexMatch'] + @suffix_match = args['suffixMatch'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRulesHeaderMatches" + end + end + + class UrlMapPathMatchersRouteRulesMatchRulesHeaderMatchesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesMatchRulesHeaderMatches.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesMatchRulesHeaderMatches.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches_range_match.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches_range_match.rb new file mode 100644 index 000000000..11ec19a0c --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_header_matches_range_match.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesMatchRulesHeaderMatchesRangeMatch + attr_reader :range_end + + attr_reader :range_start + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @range_end = args['rangeEnd'] + @range_start = args['rangeStart'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRulesHeaderMatchesRangeMatch" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters.rb new file mode 100644 index 000000000..297f454c9 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_match_rules_metadata_filters_filter_labels' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesMatchRulesMetadataFilters + attr_reader :filter_labels + + attr_reader :filter_match_criteria + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @filter_labels = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabelsArray.parse(args['filterLabels'], to_s) + @filter_match_criteria = args['filterMatchCriteria'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRulesMetadataFilters" + end + end + + class UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesMatchRulesMetadataFilters.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesMatchRulesMetadataFilters.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters_filter_labels.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters_filter_labels.rb new file mode 100644 index 000000000..eb5bd83b4 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_metadata_filters_filter_labels.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabels + attr_reader :name + + attr_reader :value + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @name = args['name'] + @value = args['value'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabels" + end + end + + class UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabelsArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabels.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesMatchRulesMetadataFiltersFilterLabels.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_query_parameter_matches.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_query_parameter_matches.rb new file mode 100644 index 000000000..7dc67cf63 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_match_rules_query_parameter_matches.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatches + attr_reader :exact_match + + attr_reader :name + + attr_reader :present_match + + attr_reader :regex_match + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @exact_match = args['exactMatch'] + @name = args['name'] + @present_match = args['presentMatch'] + @regex_match = args['regexMatch'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatches" + end + end + + class UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatchesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatches.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesMatchRulesQueryParameterMatches.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action.rb new file mode 100644 index 000000000..0e005e133 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_cors_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteAction + attr_reader :cors_policy + + attr_reader :fault_injection_policy + + attr_reader :request_mirror_policy + + attr_reader :retry_policy + + attr_reader :timeout + + attr_reader :url_rewrite + + attr_reader :weighted_backend_services + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @cors_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionCorsPolicy.new(args['corsPolicy'], to_s) + @fault_injection_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicy.new(args['faultInjectionPolicy'], to_s) + @request_mirror_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionRequestMirrorPolicy.new(args['requestMirrorPolicy'], to_s) + @retry_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionRetryPolicy.new(args['retryPolicy'], to_s) + @timeout = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionTimeout.new(args['timeout'], to_s) + @url_rewrite = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionUrlRewrite.new(args['urlRewrite'], to_s) + @weighted_backend_services = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesArray.parse(args['weightedBackendServices'], to_s) + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_cors_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_cors_policy.rb new file mode 100644 index 000000000..a6aead59d --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_cors_policy.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionCorsPolicy + attr_reader :allow_credentials + + attr_reader :allow_headers + + attr_reader :allow_methods + + attr_reader :allow_origin_regexes + + attr_reader :allow_origins + + attr_reader :disabled + + attr_reader :expose_headers + + attr_reader :max_age + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @allow_credentials = args['allowCredentials'] + @allow_headers = args['allowHeaders'] + @allow_methods = args['allowMethods'] + @allow_origin_regexes = args['allowOriginRegexes'] + @allow_origins = args['allowOrigins'] + @disabled = args['disabled'] + @expose_headers = args['exposeHeaders'] + @max_age = args['maxAge'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionCorsPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy.rb new file mode 100644 index 000000000..e079a362b --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicy + attr_reader :abort + + attr_reader :delay + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @abort = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyAbort.new(args['abort'], to_s) + @delay = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelay.new(args['delay'], to_s) + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort.rb new file mode 100644 index 000000000..ca5b45153 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_abort.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyAbort + attr_reader :http_status + + attr_reader :percentage + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @http_status = args['httpStatus'] + @percentage = args['percentage'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyAbort" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay.rb new file mode 100644 index 000000000..51539e1d0 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelay + attr_reader :fixed_delay + + attr_reader :percentage + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @fixed_delay = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelayFixedDelay.new(args['fixedDelay'], to_s) + @percentage = args['percentage'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelay" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay.rb new file mode 100644 index 000000000..c0e429012 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_fault_injection_policy_delay_fixed_delay.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelayFixedDelay + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionFaultInjectionPolicyDelayFixedDelay" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy.rb new file mode 100644 index 000000000..01f1eead7 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_request_mirror_policy.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionRequestMirrorPolicy + attr_reader :backend_service + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @backend_service = args['backendService'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionRequestMirrorPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy.rb new file mode 100644 index 000000000..b2b5d5b4c --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteActionRetryPolicy + attr_reader :num_retries + + attr_reader :per_try_timeout + + attr_reader :retry_conditions + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @num_retries = args['numRetries'] + @per_try_timeout = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionRetryPolicyPerTryTimeout.new(args['perTryTimeout'], to_s) + @retry_conditions = args['retryConditions'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionRetryPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout.rb new file mode 100644 index 000000000..e90e89d59 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_retry_policy_per_try_timeout.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionRetryPolicyPerTryTimeout + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionRetryPolicyPerTryTimeout" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout.rb new file mode 100644 index 000000000..04960153a --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_timeout.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionTimeout + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionTimeout" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite.rb new file mode 100644 index 000000000..01a8af266 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_url_rewrite.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionUrlRewrite + attr_reader :host_rewrite + + attr_reader :path_prefix_rewrite + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @host_rewrite = args['hostRewrite'] + @path_prefix_rewrite = args['pathPrefixRewrite'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionUrlRewrite" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services.rb new file mode 100644 index 000000000..6cd5dcd63 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServices + attr_reader :backend_service + + attr_reader :header_action + + attr_reader :weight + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @backend_service = args['backendService'] + @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderAction.new(args['headerAction'], to_s) + @weight = args['weight'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServices" + end + end + + class UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServices.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServices.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action.rb new file mode 100644 index 000000000..cb063eb62 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderAction + attr_reader :request_headers_to_add + + attr_reader :request_headers_to_remove + + attr_reader :response_headers_to_add + + attr_reader :response_headers_to_remove + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @request_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAddArray.parse(args['requestHeadersToAdd'], to_s) + @request_headers_to_remove = args['requestHeadersToRemove'] + @response_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAddArray.parse(args['responseHeadersToAdd'], to_s) + @response_headers_to_remove = args['responseHeadersToRemove'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb new file mode 100644 index 000000000..199e26c74 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd" + end + end + + class UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb new file mode 100644 index 000000000..9d988c712 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd" + end + end + + class UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersRouteRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules_url_redirect.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules_url_redirect.rb new file mode 100644 index 000000000..e5c33d853 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules_url_redirect.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersRouteRulesUrlRedirect + attr_reader :host_redirect + + attr_reader :https_redirect + + attr_reader :path_redirect + + attr_reader :prefix_redirect + + attr_reader :redirect_response_code + + attr_reader :strip_query + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @host_redirect = args['hostRedirect'] + @https_redirect = args['httpsRedirect'] + @path_redirect = args['pathRedirect'] + @prefix_redirect = args['prefixRedirect'] + @redirect_response_code = args['redirectResponseCode'] + @strip_query = args['stripQuery'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersRouteRulesUrlRedirect" + end + end + end + end +end diff --git a/libraries/google_compute_url_map.rb b/libraries/google_compute_url_map.rb index 2801f8be1..b2a834450 100644 --- a/libraries/google_compute_url_map.rb +++ b/libraries/google_compute_url_map.rb @@ -14,6 +14,9 @@ # # ---------------------------------------------------------------------------- require 'gcp_backend' +require 'google/compute/property/urlmap_header_action' +require 'google/compute/property/urlmap_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_header_action_response_headers_to_add' require 'google/compute/property/urlmap_host_rules' require 'google/compute/property/urlmap_path_matchers' require 'google/compute/property/urlmap_tests' @@ -28,9 +31,10 @@ class ComputeUrlMap < GcpResourceBase attr_reader :creation_timestamp attr_reader :default_service attr_reader :description - attr_reader :host_rules attr_reader :id attr_reader :fingerprint + attr_reader :header_action + attr_reader :host_rules attr_reader :name attr_reader :path_matchers attr_reader :tests @@ -46,9 +50,10 @@ def parse @creation_timestamp = parse_time_string(@fetched['creationTimestamp']) @default_service = @fetched['defaultService'] @description = @fetched['description'] - @host_rules = GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(@fetched['hostRules'], to_s) @id = @fetched['id'] @fingerprint = @fetched['fingerprint'] + @header_action = GoogleInSpec::Compute::Property::UrlMapHeaderAction.new(@fetched['headerAction'], to_s) + @host_rules = GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(@fetched['hostRules'], to_s) @name = @fetched['name'] @path_matchers = GoogleInSpec::Compute::Property::UrlMapPathMatchersArray.parse(@fetched['pathMatchers'], to_s) @tests = GoogleInSpec::Compute::Property::UrlMapTestsArray.parse(@fetched['tests'], to_s) diff --git a/libraries/google_compute_url_maps.rb b/libraries/google_compute_url_maps.rb index 3b0295761..46cba9eea 100644 --- a/libraries/google_compute_url_maps.rb +++ b/libraries/google_compute_url_maps.rb @@ -26,9 +26,10 @@ class ComputeUrlMaps < GcpResourceBase filter_table_config.add(:creation_timestamps, field: :creation_timestamp) filter_table_config.add(:default_services, field: :default_service) filter_table_config.add(:descriptions, field: :description) - filter_table_config.add(:host_rules, field: :host_rules) filter_table_config.add(:ids, field: :id) filter_table_config.add(:fingerprints, field: :fingerprint) + filter_table_config.add(:header_actions, field: :header_action) + filter_table_config.add(:host_rules, field: :host_rules) filter_table_config.add(:names, field: :name) filter_table_config.add(:path_matchers, field: :path_matchers) filter_table_config.add(:tests, field: :tests) @@ -74,9 +75,10 @@ def transformers 'creationTimestamp' => ->(obj) { return :creation_timestamp, parse_time_string(obj['creationTimestamp']) }, 'defaultService' => ->(obj) { return :default_service, obj['defaultService'] }, 'description' => ->(obj) { return :description, obj['description'] }, - 'hostRules' => ->(obj) { return :host_rules, GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(obj['hostRules'], to_s) }, 'id' => ->(obj) { return :id, obj['id'] }, 'fingerprint' => ->(obj) { return :fingerprint, obj['fingerprint'] }, + 'headerAction' => ->(obj) { return :header_action, GoogleInSpec::Compute::Property::UrlMapHeaderAction.new(obj['headerAction'], to_s) }, + 'hostRules' => ->(obj) { return :host_rules, GoogleInSpec::Compute::Property::UrlMapHostRulesArray.parse(obj['hostRules'], to_s) }, 'name' => ->(obj) { return :name, obj['name'] }, 'pathMatchers' => ->(obj) { return :path_matchers, GoogleInSpec::Compute::Property::UrlMapPathMatchersArray.parse(obj['pathMatchers'], to_s) }, 'tests' => ->(obj) { return :tests, GoogleInSpec::Compute::Property::UrlMapTestsArray.parse(obj['tests'], to_s) }, From 0969d41eaec1e96ce5062d71ac85e097574cf3e2 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 6 Dec 2019 23:03:01 +0000 Subject: [PATCH 14/19] Add spanner service account and IAM Signed-off-by: Modular Magician --- test/integration/build/gcp-mm.tf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index c150ab588..01a078f32 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -880,6 +880,12 @@ resource "google_project_service" "project" { service = var.service["name"] } +resource "google_service_account" "spanner_service_account" { + project = "${var.gcp_project_id}" + account_id = "${var.gcp_service_account_display_name}-sp" + display_name = "${var.gcp_service_account_display_name}-sp" +} + resource "google_spanner_instance" "spanner_instance" { project = "${var.gcp_project_id}" config = "${var.spannerinstance["config"]}" @@ -891,6 +897,15 @@ resource "google_spanner_instance" "spanner_instance" { } } +resource "google_spanner_instance_iam_binding" "instance" { + instance = google_spanner_instance.spanner_instance.name + role = "roles/editor" + + members = [ + "serviceAccount:${google_service_account.spanner_service_account.email}", + ] +} + resource "google_spanner_database" "database" { project = "${var.gcp_project_id}" instance = "${google_spanner_instance.spanner_instance.name}" From afd143c24ebc714729a9ede884cdf0ae8e2be45e Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 6 Dec 2019 15:17:28 -0800 Subject: [PATCH 15/19] Add spanner instance IAM policy test Signed-off-by: Sam Levenick --- .../google_spanner_instance_iam_policy.rb | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/integration/verify/controls/google_spanner_instance_iam_policy.rb diff --git a/test/integration/verify/controls/google_spanner_instance_iam_policy.rb b/test/integration/verify/controls/google_spanner_instance_iam_policy.rb new file mode 100644 index 000000000..1aeb14b6a --- /dev/null +++ b/test/integration/verify/controls/google_spanner_instance_iam_policy.rb @@ -0,0 +1,27 @@ +title 'Test GCP google_spanner_instance_iam_policy resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +spannerinstance = attribute('spannerinstance', default: { + "config": "regional-us-east1", + "name": "spinstance", + "display_name": "inspectest", + "num_nodes": 1, + "label_key": "env", + "label_value": "test" +}, description: 'Cloud Spanner definition') + +gcp_service_account_display_name = attribute(:gcp_service_account_display_name, default:'', description: 'Service account display name.') +gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources,default:0,description:'Flag to enable privileged resources requiring elevated privileges in GCP.') + +control 'google_spanner_instance_iam_policy-1.0' do + + only_if { gcp_enable_privileged_resources.to_i == 1 } + impact 1.0 + title 'google_spanner_instance_iam_policy resource test' + + describe google_spanner_instance_iam_policy(project: gcp_project_id, name: spannerinstance['name']) do + it { should exist } + its('role') { should eq "roles/editor" } + its('members') { should include "serviceAccount:#{gcp_service_account_display_name}-sp@#{gcp_project_id}.iam.gserviceaccount.com" } + end +end From 7ff4744d93ba3732dca9de58e83784b97c1c60c7 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 9 Dec 2019 11:55:53 -0800 Subject: [PATCH 16/19] Add path_rules to UrlMap (#265) Signed-off-by: Modular Magician --- docs/resources/google_compute_url_map.md | 120 +++++++++++++++++- .../compute/property/urlmap_path_matchers.rb | 6 +- .../urlmap_path_matchers_path_rules.rb | 23 +++- ...p_path_matchers_path_rules_route_action.rb | 63 +++++++++ ...ers_path_rules_route_action_cors_policy.rb | 55 ++++++++ ...les_route_action_fault_injection_policy.rb | 40 ++++++ ...ute_action_fault_injection_policy_abort.rb | 37 ++++++ ...ute_action_fault_injection_policy_delay.rb | 38 ++++++ ...ault_injection_policy_delay_fixed_delay.rb | 37 ++++++ ...ules_route_action_request_mirror_policy.rb | 34 +++++ ...rs_path_rules_route_action_retry_policy.rb | 41 ++++++ ...ute_action_retry_policy_per_try_timeout.rb | 37 ++++++ ...atchers_path_rules_route_action_timeout.rb | 37 ++++++ ...ers_path_rules_route_action_url_rewrite.rb | 37 ++++++ ..._route_action_weighted_backend_services.rb | 51 ++++++++ ...weighted_backend_services_header_action.rb | 45 +++++++ ...es_header_action_request_headers_to_add.rb | 48 +++++++ ...s_header_action_response_headers_to_add.rb | 48 +++++++ ...p_path_matchers_path_rules_url_redirect.rb | 49 +++++++ 19 files changed, 835 insertions(+), 11 deletions(-) create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb create mode 100644 libraries/google/compute/property/urlmap_path_matchers_path_rules_url_redirect.rb diff --git a/docs/resources/google_compute_url_map.md b/docs/resources/google_compute_url_map.md index 387475078..b63db82f4 100644 --- a/docs/resources/google_compute_url_map.md +++ b/docs/resources/google_compute_url_map.md @@ -78,12 +78,6 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `description`: An optional description of this resource. Provide this property when you create the resource. - * `path_rules`: The list of path rules. - - * `paths`: The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here. - - * `service`: A reference to the BackendService resource if this rule is matched. - * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. HeaderAction specified here are applied after the matching HttpRouteRule HeaderAction and before the HeaderAction in the UrlMap * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. @@ -108,6 +102,120 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `name`: The name to which this PathMatcher is referred by the HostRule. + * `path_rules`: The list of path rules. Use this list instead of routeRules when routing based on simple path matching is all that's required. The order by which path rules are specified does not matter. Matches are always done on the longest-path-first basis. For example: a pathRule with a path /a/b/c/* will match before /a/b/* irrespective of the order in which those paths appear in this list. Within a given pathMatcher, only one of pathRules or routeRules must be set. + + * `service`: The backend service resource to which traffic is directed if this rule is matched. If routeAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if service is specified, routeAction cannot contain any weightedBackendService s. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of urlRedirect, service or routeAction.weightedBackendService must be set. + + * `paths`: The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here. + + * `route_action`: In response to a matching path, the load balancer performs advanced routing actions like URL rewrites, header transformations, etc. prior to forwarding the request to the selected backend. If routeAction specifies any weightedBackendServices, service must not be set. Conversely if service is set, routeAction cannot contain any weightedBackendServices. Only one of routeAction or urlRedirect must be set. + + * `cors_policy`: The specification for allowing client side cross-origin requests. Please see W3C Recommendation for Cross Origin Resource Sharing + + * `allow_credentials`: In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This translates to the Access- Control-Allow-Credentials header. Defaults to false. + + * `allow_headers`: Specifies the content for the Access-Control-Allow-Headers header. + + * `allow_methods`: Specifies the content for the Access-Control-Allow-Methods header. + + * `allow_origin_regexes`: Specifies the regualar expression patterns that match allowed origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript An origin is allowed if it matches either allow_origins or allow_origin_regex. + + * `allow_origins`: Specifies the list of origins that will be allowed to do CORS requests. An origin is allowed if it matches either allow_origins or allow_origin_regex. + + * `disabled`: If true, specifies the CORS policy is disabled. + + * `expose_headers`: Specifies the content for the Access-Control-Expose-Headers header. + + * `max_age`: Specifies how long the results of a preflight request can be cached. This translates to the content for the Access-Control-Max-Age header. + + * `fault_injection_policy`: The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced by Loadbalancer on a percentage of requests before sending those request to the backend service. Similarly requests from clients can be aborted by the Loadbalancer for a percentage of requests. timeout and retry_policy will be ignored by clients that are configured with a fault_injection_policy. + + * `abort`: The specification for how client requests are aborted as part of fault injection. + + * `http_status`: The HTTP status code used to abort the request. The value must be between 200 and 599 inclusive. + + * `percentage`: The percentage of traffic (connections/operations/requests) which will be aborted as part of fault injection. The value must be between 0.0 and 100.0 inclusive. + + * `delay`: The specification for how client requests are delayed as part of fault injection, before being sent to a backend service. + + * `fixed_delay`: Specifies the value of the fixed delay interval. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `percentage`: The percentage of traffic (connections/operations/requests) on which delay will be introduced as part of fault injection. The value must be between 0.0 and 100.0 inclusive. + + * `request_mirror_policy`: Specifies the policy on how requests intended for the route's backends are shadowed to a separate mirrored backend service. Loadbalancer does not wait for responses from the shadow service. Prior to sending traffic to the shadow service, the host / authority header is suffixed with -shadow. + + * `backend_service`: The BackendService resource being mirrored to. + + * `retry_policy`: Specifies the retry policy associated with this route. + + * `num_retries`: Specifies the allowed number retries. This number must be > 0. + + * `per_try_timeout`: Specifies a non-zero timeout per retry attempt. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `retry_conditions`: Specfies one or more conditions when this retry rule applies. Valid values are: - 5xx: Loadbalancer will attempt a retry if the backend service responds with any 5xx response code, or if the backend service does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: Loadbalancer will retry on failures connecting to backend services, for example due to connection timeouts. - retriable-4xx: Loadbalancer will retry for retriable 4xx response codes. Currently the only retriable error supported is 409. - refused-stream: Loadbalancer will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Loadbalancer will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Loadbalancer will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Loadbalancer will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Loadbalancer will retry if the gRPC status code in the response header is set to unavailable + + * `timeout`: Specifies the timeout for the selected route. Timeout is computed from the time the request is has been fully processed (i.e. end-of-stream) up until the response has been completely processed. Timeout includes all retries. If not specified, the default value is 15 seconds. + + * `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. + + * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. + + * `url_rewrite`: The spec to modify the URL of the request, prior to forwarding the request to the matched service + + * `host_rewrite`: Prior to forwarding the request to the selected service, the request's host header is replaced with contents of hostRewrite. The value must be between 1 and 255 characters. + + * `path_prefix_rewrite`: Prior to forwarding the request to the selected backend service, the matching portion of the request's path is replaced by pathPrefixRewrite. The value must be between 1 and 1024 characters. + + * `weighted_backend_services`: A list of weighted backend services to send traffic to when a route match occurs. The weights determine the fraction of traffic that flows to their corresponding backend service. If all traffic needs to go to a single backend service, there must be one weightedBackendService with weight set to a non 0 number. Once a backendService is identified and before forwarding the request to the backend service, advanced routing actions like Url rewrites and header transformations are applied depending on additional settings specified in this HttpRouteAction. + + * `backend_service`: The default BackendService resource. Before forwarding the request to backendService, the loadbalancer applies any relevant headerActions specified as part of this backendServiceWeight. + + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. headerAction specified here take effect before headerAction in the enclosing HttpRouteRule, PathMatcher and UrlMap. + + * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `request_headers_to_remove`: A list of header names for headers that need to be removed from the request prior to forwarding the request to the backendService. + + * `response_headers_to_add`: Headers to add the response prior to sending the response back to the client. + + * `header_name`: The name of the header. + + * `header_value`: The value of the header to add. + + * `replace`: If false, headerValue is appended to any values that already exist for the header. If true, headerValue is set for the header, discarding any values that were set for that header. + + * `response_headers_to_remove`: A list of header names for headers that need to be removed from the response prior to sending the response back to the client. + + * `weight`: Specifies the fraction of traffic sent to backendService, computed as weight / (sum of all weightedBackendService weights in routeAction) . The selection of a backend service is determined only for new traffic. Once a user's request has been directed to a backendService, subsequent requests will be sent to the same backendService as determined by the BackendService's session affinity policy. The value must be between 0 and 1000 + + * `url_redirect`: When a path pattern is matched, the request is redirected to a URL specified by urlRedirect. If urlRedirect is specified, service or routeAction must not be set. + + * `host_redirect`: The host that will be used in the redirect response instead of the one that was supplied in the request. The value must be between 1 and 255 characters. + + * `https_redirect`: If set to true, the URL scheme in the redirected request is set to https. If set to false, the URL scheme of the redirected request will remain the same as that of the request. This must only be set for UrlMaps used in TargetHttpProxys. Setting this true for TargetHttpsProxy is not permitted. Defaults to false. + + * `path_redirect`: The path that will be used in the redirect response instead of the one that was supplied in the request. Only one of pathRedirect or prefixRedirect must be specified. The value must be between 1 and 1024 characters. + + * `prefix_redirect`: The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch, retaining the remaining portion of the URL before redirecting the request. + + * `redirect_response_code`: The HTTP Status code to use for this RedirectAction. Supported values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case, the request method will be retained. - PERMANENT_REDIRECT, which corresponds to 308. In this case, the request method will be retained. + + * `strip_query`: If set to true, any accompanying query portion of the original URL is removed prior to redirecting the request. If set to false, the query portion of the original URL is retained. + * `route_rules`: The list of ordered HTTP route rules. Use this list instead of pathRules when advanced route matching and routing actions are desired. The order of specifying routeRules matters: the first rule that matches will cause its specified routing action to take effect. Within a given pathMatcher, only one of pathRules or routeRules must be set. routeRules are not supported in UrlMaps intended for External load balancers. * `priority`: For routeRules within a given pathMatcher, priority determines the order in which load balancer will interpret routeRules. RouteRules are evaluated in order of priority, from the lowest to highest number. The priority of a rule decreases as its number increases (1, 2, 3, N+1). The first rule that matches the request is applied. You cannot configure two or more routeRules with the same priority. Priority for each rule must be set to a number between 0 and 2147483647 inclusive. Priority numbers can have gaps, which enable you to add or remove rules in the future without affecting the rest of the rules. For example, 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future without any impact on existing rules. diff --git a/libraries/google/compute/property/urlmap_path_matchers.rb b/libraries/google/compute/property/urlmap_path_matchers.rb index a987f6cd4..9fd1ee95d 100644 --- a/libraries/google/compute/property/urlmap_path_matchers.rb +++ b/libraries/google/compute/property/urlmap_path_matchers.rb @@ -26,12 +26,12 @@ class UrlMapPathMatchers attr_reader :description - attr_reader :path_rules - attr_reader :header_action attr_reader :name + attr_reader :path_rules + attr_reader :route_rules def initialize(args = nil, parent_identifier = nil) @@ -39,9 +39,9 @@ def initialize(args = nil, parent_identifier = nil) @parent_identifier = parent_identifier @default_service = args['defaultService'] @description = args['description'] - @path_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesArray.parse(args['pathRules'], to_s) @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersHeaderAction.new(args['headerAction'], to_s) @name = args['name'] + @path_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesArray.parse(args['pathRules'], to_s) @route_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesArray.parse(args['routeRules'], to_s) end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules.rb index 6202f915e..0739ba173 100644 --- a/libraries/google/compute/property/urlmap_path_matchers_path_rules.rb +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules.rb @@ -13,19 +13,38 @@ # CONTRIBUTING.md located at the root of this package. # # ---------------------------------------------------------------------------- +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services' +require 'google/compute/property/urlmap_path_matchers_path_rules_url_redirect' module GoogleInSpec module Compute module Property class UrlMapPathMatchersPathRules + attr_reader :service + attr_reader :paths - attr_reader :service + attr_reader :route_action + + attr_reader :url_redirect def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier - @paths = args['paths'] @service = args['service'] + @paths = args['paths'] + @route_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteAction.new(args['routeAction'], to_s) + @url_redirect = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesUrlRedirect.new(args['urlRedirect'], to_s) end def to_s diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action.rb new file mode 100644 index 000000000..524315eb6 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_cors_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteAction + attr_reader :cors_policy + + attr_reader :fault_injection_policy + + attr_reader :request_mirror_policy + + attr_reader :retry_policy + + attr_reader :timeout + + attr_reader :url_rewrite + + attr_reader :weighted_backend_services + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @cors_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionCorsPolicy.new(args['corsPolicy'], to_s) + @fault_injection_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicy.new(args['faultInjectionPolicy'], to_s) + @request_mirror_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionRequestMirrorPolicy.new(args['requestMirrorPolicy'], to_s) + @retry_policy = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionRetryPolicy.new(args['retryPolicy'], to_s) + @timeout = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionTimeout.new(args['timeout'], to_s) + @url_rewrite = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionUrlRewrite.new(args['urlRewrite'], to_s) + @weighted_backend_services = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesArray.parse(args['weightedBackendServices'], to_s) + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy.rb new file mode 100644 index 000000000..559ab6054 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_cors_policy.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionCorsPolicy + attr_reader :allow_credentials + + attr_reader :allow_headers + + attr_reader :allow_methods + + attr_reader :allow_origin_regexes + + attr_reader :allow_origins + + attr_reader :disabled + + attr_reader :expose_headers + + attr_reader :max_age + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @allow_credentials = args['allowCredentials'] + @allow_headers = args['allowHeaders'] + @allow_methods = args['allowMethods'] + @allow_origin_regexes = args['allowOriginRegexes'] + @allow_origins = args['allowOrigins'] + @disabled = args['disabled'] + @expose_headers = args['exposeHeaders'] + @max_age = args['maxAge'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionCorsPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy.rb new file mode 100644 index 000000000..d22ca1709 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicy + attr_reader :abort + + attr_reader :delay + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @abort = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyAbort.new(args['abort'], to_s) + @delay = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelay.new(args['delay'], to_s) + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort.rb new file mode 100644 index 000000000..fcc1b896a --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_abort.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyAbort + attr_reader :http_status + + attr_reader :percentage + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @http_status = args['httpStatus'] + @percentage = args['percentage'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyAbort" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay.rb new file mode 100644 index 000000000..225070bca --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelay + attr_reader :fixed_delay + + attr_reader :percentage + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @fixed_delay = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelayFixedDelay.new(args['fixedDelay'], to_s) + @percentage = args['percentage'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelay" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay.rb new file mode 100644 index 000000000..752c9e6a9 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_fault_injection_policy_delay_fixed_delay.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelayFixedDelay + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionFaultInjectionPolicyDelayFixedDelay" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy.rb new file mode 100644 index 000000000..6fc03ef36 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_request_mirror_policy.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionRequestMirrorPolicy + attr_reader :backend_service + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @backend_service = args['backendService'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionRequestMirrorPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy.rb new file mode 100644 index 000000000..85a165d31 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteActionRetryPolicy + attr_reader :num_retries + + attr_reader :per_try_timeout + + attr_reader :retry_conditions + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @num_retries = args['numRetries'] + @per_try_timeout = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionRetryPolicyPerTryTimeout.new(args['perTryTimeout'], to_s) + @retry_conditions = args['retryConditions'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionRetryPolicy" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout.rb new file mode 100644 index 000000000..dfafc2b1a --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_retry_policy_per_try_timeout.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionRetryPolicyPerTryTimeout + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionRetryPolicyPerTryTimeout" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout.rb new file mode 100644 index 000000000..e9ea3911c --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_timeout.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionTimeout + attr_reader :nanos + + attr_reader :seconds + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @nanos = args['nanos'] + @seconds = args['seconds'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionTimeout" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite.rb new file mode 100644 index 000000000..7fa219df9 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_url_rewrite.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionUrlRewrite + attr_reader :host_rewrite + + attr_reader :path_prefix_rewrite + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @host_rewrite = args['hostRewrite'] + @path_prefix_rewrite = args['pathPrefixRewrite'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionUrlRewrite" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services.rb new file mode 100644 index 000000000..1f506bc3b --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteActionWeightedBackendServices + attr_reader :backend_service + + attr_reader :header_action + + attr_reader :weight + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @backend_service = args['backendService'] + @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderAction.new(args['headerAction'], to_s) + @weight = args['weight'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionWeightedBackendServices" + end + end + + class UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersPathRulesRouteActionWeightedBackendServices.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersPathRulesRouteActionWeightedBackendServices.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action.rb new file mode 100644 index 000000000..88bb4d901 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add' +require 'google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add' +module GoogleInSpec + module Compute + module Property + class UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderAction + attr_reader :request_headers_to_add + + attr_reader :request_headers_to_remove + + attr_reader :response_headers_to_add + + attr_reader :response_headers_to_remove + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @request_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAddArray.parse(args['requestHeadersToAdd'], to_s) + @request_headers_to_remove = args['requestHeadersToRemove'] + @response_headers_to_add = GoogleInSpec::Compute::Property::UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAddArray.parse(args['responseHeadersToAdd'], to_s) + @response_headers_to_remove = args['responseHeadersToRemove'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderAction" + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb new file mode 100644 index 000000000..f550e2a83 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_request_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd" + end + end + + class UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionRequestHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb new file mode 100644 index 000000000..fc401d197 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_route_action_weighted_backend_services_header_action_response_headers_to_add.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd + attr_reader :header_name + + attr_reader :header_value + + attr_reader :replace + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @header_name = args['headerName'] + @header_value = args['headerValue'] + @replace = args['replace'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd" + end + end + + class UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAddArray + def self.parse(value, parent_identifier) + return if value.nil? + return UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| UrlMapPathMatchersPathRulesRouteActionWeightedBackendServicesHeaderActionResponseHeadersToAdd.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google/compute/property/urlmap_path_matchers_path_rules_url_redirect.rb b/libraries/google/compute/property/urlmap_path_matchers_path_rules_url_redirect.rb new file mode 100644 index 000000000..9f8f071c4 --- /dev/null +++ b/libraries/google/compute/property/urlmap_path_matchers_path_rules_url_redirect.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# 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 UrlMapPathMatchersPathRulesUrlRedirect + attr_reader :host_redirect + + attr_reader :https_redirect + + attr_reader :path_redirect + + attr_reader :prefix_redirect + + attr_reader :redirect_response_code + + attr_reader :strip_query + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @host_redirect = args['hostRedirect'] + @https_redirect = args['httpsRedirect'] + @path_redirect = args['pathRedirect'] + @prefix_redirect = args['prefixRedirect'] + @redirect_response_code = args['redirectResponseCode'] + @strip_query = args['stripQuery'] + end + + def to_s + "#{@parent_identifier} UrlMapPathMatchersPathRulesUrlRedirect" + end + end + end + end +end From 4685dcca45d6b553134a4669b5607c8168153218 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 9 Dec 2019 12:53:57 -0800 Subject: [PATCH 17/19] update compute disk documentation (#267) Signed-off-by: Modular Magician --- docs/resources/google_compute_disk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/google_compute_disk.md b/docs/resources/google_compute_disk.md index 8b0041bc9..189f06a98 100644 --- a/docs/resources/google_compute_disk.md +++ b/docs/resources/google_compute_disk.md @@ -81,7 +81,7 @@ Properties that can be accessed from the `google_compute_disk` resource: * `sha256`: The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource. - * `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS. + * `kms_key_name`: The name of the encryption key that is stored in Google Cloud KMS. Your project's Compute Engine System service account (`service-{{PROJECT_NUMBER}}@compute-system.iam.gserviceaccount.com`) must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature. * `source_snapshot`: The source snapshot used to create this disk. You can provide this as a partial or full URL to the resource. If the snapshot is in another project than this disk, you must supply a full URL. For example, the following are valid values: * `https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot` * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` From 8b46d0a6905f22efe995e18973d06b9f4ec1a12f Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 9 Dec 2019 15:18:19 -0800 Subject: [PATCH 18/19] Add path_rules to RegionUrlMap (#269) Signed-off-by: Modular Magician --- docs/resources/google_compute_url_map.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/google_compute_url_map.md b/docs/resources/google_compute_url_map.md index b63db82f4..bf5e2ae9c 100644 --- a/docs/resources/google_compute_url_map.md +++ b/docs/resources/google_compute_url_map.md @@ -160,7 +160,7 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `seconds`: Span of time at a resolution of a second. Must be from 0 to 315,576,000,000 inclusive. - * `retry_conditions`: Specfies one or more conditions when this retry rule applies. Valid values are: - 5xx: Loadbalancer will attempt a retry if the backend service responds with any 5xx response code, or if the backend service does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: Loadbalancer will retry on failures connecting to backend services, for example due to connection timeouts. - retriable-4xx: Loadbalancer will retry for retriable 4xx response codes. Currently the only retriable error supported is 409. - refused-stream: Loadbalancer will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Loadbalancer will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Loadbalancer will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Loadbalancer will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Loadbalancer will retry if the gRPC status code in the response header is set to unavailable + * `retry_conditions`: Specifies one or more conditions when this retry rule applies. Valid values are: - 5xx: Loadbalancer will attempt a retry if the backend service responds with any 5xx response code, or if the backend service does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams. - gateway-error: Similar to 5xx, but only applies to response codes 502, 503 or 504. - connect-failure: Loadbalancer will retry on failures connecting to backend services, for example due to connection timeouts. - retriable-4xx: Loadbalancer will retry for retriable 4xx response codes. Currently the only retriable error supported is 409. - refused-stream: Loadbalancer will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Loadbalancer will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Loadbalancer will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Loadbalancer will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Loadbalancer will retry if the gRPC status code in the response header is set to unavailable * `timeout`: Specifies the timeout for the selected route. Timeout is computed from the time the request is has been fully processed (i.e. end-of-stream) up until the response has been completely processed. Timeout includes all retries. If not specified, the default value is 15 seconds. From d7138272374753efa90513d3849b37663c6edbe5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 9 Dec 2019 17:30:40 -0800 Subject: [PATCH 19/19] Add route_rules to RegionUrlMap (#270) Signed-off-by: Modular Magician --- docs/resources/google_compute_url_map.md | 2 ++ .../compute/property/urlmap_path_matchers_route_rules.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/resources/google_compute_url_map.md b/docs/resources/google_compute_url_map.md index bf5e2ae9c..2f39c2dc6 100644 --- a/docs/resources/google_compute_url_map.md +++ b/docs/resources/google_compute_url_map.md @@ -220,6 +220,8 @@ Properties that can be accessed from the `google_compute_url_map` resource: * `priority`: For routeRules within a given pathMatcher, priority determines the order in which load balancer will interpret routeRules. RouteRules are evaluated in order of priority, from the lowest to highest number. The priority of a rule decreases as its number increases (1, 2, 3, N+1). The first rule that matches the request is applied. You cannot configure two or more routeRules with the same priority. Priority for each rule must be set to a number between 0 and 2147483647 inclusive. Priority numbers can have gaps, which enable you to add or remove rules in the future without affecting the rest of the rules. For example, 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future without any impact on existing rules. + * `service`: The backend service resource to which traffic is directed if this rule is matched. If routeAction is additionally specified, advanced routing actions like URL Rewrites, etc. take effect prior to sending the request to the backend. However, if service is specified, routeAction cannot contain any weightedBackendService s. Conversely, if routeAction specifies any weightedBackendServices, service must not be specified. Only one of urlRedirect, service or routeAction.weightedBackendService must be set. + * `header_action`: Specifies changes to request and response headers that need to take effect for the selected backendService. The headerAction specified here are applied before the matching pathMatchers[].headerAction and after pathMatchers[].routeRules[].r outeAction.weightedBackendService.backendServiceWeightAction[].headerAction * `request_headers_to_add`: Headers to add to a matching request prior to forwarding the request to the backendService. diff --git a/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb b/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb index faa6209d8..7ff7a81ab 100644 --- a/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb +++ b/libraries/google/compute/property/urlmap_path_matchers_route_rules.rb @@ -36,6 +36,8 @@ module Property class UrlMapPathMatchersRouteRules attr_reader :priority + attr_reader :service + attr_reader :header_action attr_reader :match_rules @@ -48,6 +50,7 @@ def initialize(args = nil, parent_identifier = nil) return if args.nil? @parent_identifier = parent_identifier @priority = args['priority'] + @service = args['service'] @header_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesHeaderAction.new(args['headerAction'], to_s) @match_rules = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesMatchRulesArray.parse(args['matchRules'], to_s) @route_action = GoogleInSpec::Compute::Property::UrlMapPathMatchersRouteRulesRouteAction.new(args['routeAction'], to_s)