diff --git a/Gemfile b/Gemfile index df28b6c9d..6cd3fe881 100644 --- a/Gemfile +++ b/Gemfile @@ -13,5 +13,6 @@ group :development do gem 'passgen' gem 'pry-coolline' gem 'rake' + gem 'vcr' gem 'webmock' end diff --git a/Rakefile b/Rakefile index e6a69e743..1805310f3 100644 --- a/Rakefile +++ b/Rakefile @@ -43,7 +43,7 @@ namespace :test do task :init_workspace do # Initialize terraform workspace - cmd = format("cd %s/build/ && terraform init", integration_dir) + cmd = format("cd %s/build/ && terraform init -upgrade", integration_dir) sh(cmd) end diff --git a/docs/resources/google_bigquery_dataset.md b/docs/resources/google_bigquery_dataset.md index 769dc9462..ab2edc4a0 100644 --- a/docs/resources/google_bigquery_dataset.md +++ b/docs/resources/google_bigquery_dataset.md @@ -71,3 +71,9 @@ Properties that can be accessed from the `google_bigquery_dataset` resource: * `last_modified_time`: The date when this dataset or any of its tables was last modified, in milliseconds since the epoch. * `location`: The geographic location where the dataset should reside. Possible values include EU and US. The default value is US. + + + +## GCP Permissions + +Ensure the [BigQuery API](https://console.cloud.google.com/apis/library/bigquery-json.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigquery_datasets.md b/docs/resources/google_bigquery_datasets.md index f8412c64c..9d3e0b494 100644 --- a/docs/resources/google_bigquery_datasets.md +++ b/docs/resources/google_bigquery_datasets.md @@ -28,3 +28,7 @@ See [google_bigquery_dataset.md](google_bigquery_dataset.md) for more detailed i ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [BigQuery API](https://console.cloud.google.com/apis/library/bigquery-json.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigquery_table.md b/docs/resources/google_bigquery_table.md new file mode 100644 index 000000000..ed17694c7 --- /dev/null +++ b/docs/resources/google_bigquery_table.md @@ -0,0 +1,117 @@ +--- +title: About the google_bigquery_table resource +platform: gcp +--- + +## Syntax +A `google_bigquery_table` is used to test a Google Table resource + +## Examples +``` +describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: 'inspec_gcp_bigquery_table') do + it { should exist } + + its('expiration_time') { should cmp '1738882264000' } + its('time_partitioning.type') { should eq 'DAY' } + its('description') { should eq 'A BigQuery table' } +end + +describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: 'nonexistent') do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_bigquery_table` resource: + + * `table_reference`: Reference describing the ID of this table + + * `datasetId`: The ID of the dataset containing this table + + * `projectId`: The ID of the project containing this table + + * `tableId`: The ID of the the table + + * `creation_time`: The time when this dataset was created, in milliseconds since the epoch. + + * `description`: A user-friendly description of the dataset + + * `friendly_name`: A descriptive name for this table + + * `id`: An opaque ID uniquely identifying the table. + + * `labels`: The labels associated with this dataset. You can use these to organize and group your datasets + + * `last_modified_time`: The time when this table was last modified, in milliseconds since the epoch. + + * `location`: The geographic location where the table resides. This value is inherited from the dataset. + + * `name`: Name of the table + + * `num_bytes`: The size of this table in bytes, excluding any data in the streaming buffer. + + * `num_long_term_bytes`: The number of bytes in the table that are considered "long-term storage". + + * `num_rows`: The number of rows of data in this table, excluding any data in the streaming buffer. + + * `type`: Describes the table type + + * `view`: The view definition. + + * `useLegacySql`: Specifies whether to use BigQuery's legacy SQL for this view + + * `userDefinedFunctionResources`: Describes user-defined function resources used in the query. + + * `time_partitioning`: If specified, configures time-based partitioning for this table. + + * `expirationMs`: Number of milliseconds for which to keep the storage for a partition. + + * `type`: The only type supported is DAY, which will generate one partition per day. + + * `streaming_buffer`: Contains information regarding this table's streaming buffer, if one is present. This field will be absent if the table is not being streamed to or if there is no data in the streaming buffer. + + * `estimatedBytes`: A lower-bound estimate of the number of bytes currently in the streaming buffer. + + * `estimatedRows`: A lower-bound estimate of the number of rows currently in the streaming buffer. + + * `oldestEntryTime`: Contains the timestamp of the oldest entry in the streaming buffer, in milliseconds since the epoch, if the streaming buffer is available. + + * `schema`: Describes the schema of this table + + * `fields`: Describes the fields in a table. + + * `encryption_configuration`: Custom encryption configuration + + * `kmsKeyName`: Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. The BigQuery Service Account associated with your project requires access to this encryption key. + + * `expiration_time`: The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. + + * `external_data_configuration`: Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. + + * `autodetect`: Try to detect schema and format options automatically. Any option specified explicitly will be honored. + + * `compression`: The compression type of the data source + + * `ignoreUnknownValues`: Indicates if BigQuery should allow extra values that are not represented in the table schema + + * `maxBadRecords`: The maximum number of bad records that BigQuery can ignore when reading data + + * `sourceFormat`: The data format + + * `sourceUris`: The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified. Also, the '*' wildcard character is not allowed. + + * `schema`: The schema for the data. Schema is required for CSV and JSON formats + + * `googleSheetsOptions`: Additional options if sourceFormat is set to GOOGLE_SHEETS. + + * `csvOptions`: Additional properties to set if sourceFormat is set to CSV. + + * `bigtableOptions`: Additional options if sourceFormat is set to BIGTABLE. + + * `dataset`: Name of the dataset + + + +## GCP Permissions + +Ensure the [BigQuery API](https://console.cloud.google.com/apis/library/bigquery-json.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigquery_tables.md b/docs/resources/google_bigquery_tables.md new file mode 100644 index 000000000..57d390276 --- /dev/null +++ b/docs/resources/google_bigquery_tables.md @@ -0,0 +1,51 @@ +--- +title: About the google_bigquery_tables resource +platform: gcp +--- + +## Syntax +A `google_bigquery_tables` is used to test a Google Table resource + +## Examples +``` +describe.one do + google_bigquery_tables(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset').table_references.each do |table_reference| + describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: table_reference.table_id) do + its('expiration_time') { should cmp '1738882264000' } + its('description') { should eq 'A BigQuery table' } + end + end +end +``` + +## Properties +Properties that can be accessed from the `google_bigquery_tables` resource: + +See [google_bigquery_table.md](google_bigquery_table.md) for more detailed information + * `table_references`: an array of `google_bigquery_table` table_reference + * `creation_times`: an array of `google_bigquery_table` creation_time + * `friendly_names`: an array of `google_bigquery_table` friendly_name + * `ids`: an array of `google_bigquery_table` id + * `labels`: an array of `google_bigquery_table` labels + * `last_modified_times`: an array of `google_bigquery_table` last_modified_time + * `locations`: an array of `google_bigquery_table` location + * `num_bytes`: an array of `google_bigquery_table` num_bytes + * `num_long_term_bytes`: an array of `google_bigquery_table` num_long_term_bytes + * `num_rows`: an array of `google_bigquery_table` num_rows + * `types`: an array of `google_bigquery_table` type + * `views`: an array of `google_bigquery_table` view + * `time_partitionings`: an array of `google_bigquery_table` time_partitioning + * `streaming_buffers`: an array of `google_bigquery_table` streaming_buffer + * `schemas`: an array of `google_bigquery_table` schema + * `encryption_configurations`: an array of `google_bigquery_table` encryption_configuration + * `expiration_times`: an array of `google_bigquery_table` expiration_time + * `external_data_configurations`: an array of `google_bigquery_table` external_data_configuration + * `datasets`: an array of `google_bigquery_table` dataset + +## Filter Criteria +This resource supports all of the above properties as filter criteria, which can be used +with `where` as a block or a method. + +## GCP Permissions + +Ensure the [BigQuery API](https://console.cloud.google.com/apis/library/bigquery-json.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_cloudbuild_trigger.md b/docs/resources/google_cloudbuild_trigger.md index 0cb4e3f4a..f58eb86d8 100644 --- a/docs/resources/google_cloudbuild_trigger.md +++ b/docs/resources/google_cloudbuild_trigger.md @@ -35,7 +35,7 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource: * `substitutions`: Substitutions data for Build resource. - * `filename`: Path, from the source root, to a file whose contents is used for the template. + * `filename`: Path, from the source root, to a file whose contents is used for the template. Either a filename or build template must be provided. * `ignored_files`: ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match extended with support for `**`. If ignoredFiles and changed files are both empty, then they are not used to determine whether or not to trigger a build. If ignoredFiles is not empty, then we ignore any files that match any of the ignored_file globs. If the change has no files that are outside of the ignoredFiles globs, then we do not trigger a build. @@ -49,16 +49,22 @@ Properties that can be accessed from the `google_cloudbuild_trigger` resource: * `dir`: Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's dir is specified and is an absolute path, this value is ignored for that step's execution. - * `branchName`: Name of the branch to build. + * `branchName`: Name of the branch to build. Exactly one a of branch name, tag, or commit SHA must be provided. - * `tagName`: Name of the tag to build. + * `tagName`: Name of the tag to build. Exactly one of a branch name, tag, or commit SHA must be provided. - * `commitSha`: Explicit commit SHA to build. + * `commitSha`: Explicit commit SHA to build. Exactly one of a branch name, tag, or commit SHA must be provided. - * `build`: Contents of the build template. + * `build`: Contents of the build template. Either a filename or build template must be provided. * `tags`: Tags for annotation of a Build. These are not docker tags. * `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. * `steps`: The operations to be performed on the workspace. + + + +## GCP Permissions + +Ensure the [Cloud Build API](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_cloudbuild_triggers.md b/docs/resources/google_cloudbuild_triggers.md index 65b56a458..0ba4f33e4 100644 --- a/docs/resources/google_cloudbuild_triggers.md +++ b/docs/resources/google_cloudbuild_triggers.md @@ -40,3 +40,7 @@ See [google_cloudbuild_trigger.md](google_cloudbuild_trigger.md) for more detail ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Cloud Build API](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_autoscaler.md b/docs/resources/google_compute_autoscaler.md index 080cb7b69..5b5f78a3c 100644 --- a/docs/resources/google_compute_autoscaler.md +++ b/docs/resources/google_compute_autoscaler.md @@ -51,3 +51,9 @@ Properties that can be accessed from the `google_compute_autoscaler` resource: * `target`: URL of the managed instance group that this autoscaler will scale. * `zone`: URL of the zone where the instance group resides. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_autoscalers.md b/docs/resources/google_compute_autoscalers.md index 5012cc96b..b71a0c9e2 100644 --- a/docs/resources/google_compute_autoscalers.md +++ b/docs/resources/google_compute_autoscalers.md @@ -36,3 +36,7 @@ See [google_compute_autoscaler.md](google_compute_autoscaler.md) for more detail ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_backend_service.md b/docs/resources/google_compute_backend_service.md index 8a7d426eb..8d39ef8ae 100644 --- a/docs/resources/google_compute_backend_service.md +++ b/docs/resources/google_compute_backend_service.md @@ -88,3 +88,9 @@ Properties that can be accessed from the `google_compute_backend_service` resour * `session_affinity`: Type of session affinity to use. The default is NONE. When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, or CLIENT_IP_PORT_PROTO. When the protocol is UDP, this field is not used. * `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]. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_backend_services.md b/docs/resources/google_compute_backend_services.md index c8373da98..bbbd8f0b8 100644 --- a/docs/resources/google_compute_backend_services.md +++ b/docs/resources/google_compute_backend_services.md @@ -42,3 +42,7 @@ See [google_compute_backend_service.md](google_compute_backend_service.md) for m ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_disk.md b/docs/resources/google_compute_disk.md index bfada18ce..4aca7ef57 100644 --- a/docs/resources/google_compute_disk.md +++ b/docs/resources/google_compute_disk.md @@ -91,3 +91,9 @@ 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. * `source_snapshot_id`: The unique ID of the snapshot used to create this disk. This value identifies the exact snapshot that was used to create this persistent disk. For example, if you created the persistent disk from a snapshot that was later deleted and recreated under the same name, the source snapshot ID would identify the exact version of the snapshot that was used. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_disks.md b/docs/resources/google_compute_disks.md index b9c7e43fc..f6a5d8cbd 100644 --- a/docs/resources/google_compute_disks.md +++ b/docs/resources/google_compute_disks.md @@ -44,3 +44,7 @@ See [google_compute_disk.md](google_compute_disk.md) for more detailed informati ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_global_address.md b/docs/resources/google_compute_global_address.md index b00f2ce7e..824cc9a7d 100644 --- a/docs/resources/google_compute_global_address.md +++ b/docs/resources/google_compute_global_address.md @@ -36,3 +36,9 @@ Properties that can be accessed from the `google_compute_global_address` resourc * `region`: A reference to the region where the regional address resides. * `address_type`: The type of the address to reserve, default is EXTERNAL. * EXTERNAL indicates public/external single IP address. * INTERNAL indicates internal IP ranges belonging to some network. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_global_addresses.md b/docs/resources/google_compute_global_addresses.md index 4c9a7530f..47c26b221 100644 --- a/docs/resources/google_compute_global_addresses.md +++ b/docs/resources/google_compute_global_addresses.md @@ -31,3 +31,7 @@ See [google_compute_global_address.md](google_compute_global_address.md) for mor ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_global_forwarding_rule.md b/docs/resources/google_compute_global_forwarding_rule.md index f6256481e..f1188e99d 100644 --- a/docs/resources/google_compute_global_forwarding_rule.md +++ b/docs/resources/google_compute_global_forwarding_rule.md @@ -51,3 +51,9 @@ Properties that can be accessed from the `google_compute_global_forwarding_rule` * `region`: A reference to the region where the regional forwarding rule resides. This field is not applicable to global forwarding rules. * `target`: This target must be a global load balancing resource. The forwarded traffic must be of a type appropriate to the target object. Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_global_forwarding_rules.md b/docs/resources/google_compute_global_forwarding_rules.md index e48105f97..a655b2fc2 100644 --- a/docs/resources/google_compute_global_forwarding_rules.md +++ b/docs/resources/google_compute_global_forwarding_rules.md @@ -37,3 +37,7 @@ See [google_compute_global_forwarding_rule.md](google_compute_global_forwarding_ ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_health_check.md b/docs/resources/google_compute_health_check.md index 5687272c5..9740c6936 100644 --- a/docs/resources/google_compute_health_check.md +++ b/docs/resources/google_compute_health_check.md @@ -91,3 +91,9 @@ Properties that can be accessed from the `google_compute_health_check` resource: * `portName`: Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name are defined, port takes precedence. * `proxyHeader`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_health_checks.md b/docs/resources/google_compute_health_checks.md index a11c784ba..b9bbf6c73 100644 --- a/docs/resources/google_compute_health_checks.md +++ b/docs/resources/google_compute_health_checks.md @@ -35,3 +35,7 @@ See [google_compute_health_check.md](google_compute_health_check.md) for more de ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_http_health_check.md b/docs/resources/google_compute_http_health_check.md index 1bb332599..3fbac5e64 100644 --- a/docs/resources/google_compute_http_health_check.md +++ b/docs/resources/google_compute_http_health_check.md @@ -44,3 +44,9 @@ Properties that can be accessed from the `google_compute_http_health_check` reso * `timeout_sec`: How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. * `unhealthy_threshold`: A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_http_health_checks.md b/docs/resources/google_compute_http_health_checks.md index d0a413fee..346b230ac 100644 --- a/docs/resources/google_compute_http_health_checks.md +++ b/docs/resources/google_compute_http_health_checks.md @@ -34,3 +34,7 @@ See [google_compute_http_health_check.md](google_compute_http_health_check.md) f ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_https_health_check.md b/docs/resources/google_compute_https_health_check.md index 3b550e484..c6e184b72 100644 --- a/docs/resources/google_compute_https_health_check.md +++ b/docs/resources/google_compute_https_health_check.md @@ -45,3 +45,9 @@ Properties that can be accessed from the `google_compute_https_health_check` res * `timeout_sec`: How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec. * `unhealthy_threshold`: A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_https_health_checks.md b/docs/resources/google_compute_https_health_checks.md index 4fa507d2b..d7bc536dd 100644 --- a/docs/resources/google_compute_https_health_checks.md +++ b/docs/resources/google_compute_https_health_checks.md @@ -34,3 +34,7 @@ See [google_compute_https_health_check.md](google_compute_https_health_check.md) ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_instance_group_manager.md b/docs/resources/google_compute_instance_group_manager.md index 378467686..90195eb59 100644 --- a/docs/resources/google_compute_instance_group_manager.md +++ b/docs/resources/google_compute_instance_group_manager.md @@ -71,3 +71,9 @@ Properties that can be accessed from the `google_compute_instance_group_manager` * `target_size`: The target number of running instances for this managed instance group. Deleting or abandoning instances reduces this number. Resizing the group changes this number. * `zone`: The zone the managed instance group resides. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_instance_group_managers.md b/docs/resources/google_compute_instance_group_managers.md index 2bcb6fde1..ff0151a0b 100644 --- a/docs/resources/google_compute_instance_group_managers.md +++ b/docs/resources/google_compute_instance_group_managers.md @@ -34,3 +34,7 @@ See [google_compute_instance_group_manager.md](google_compute_instance_group_man ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_instance_template.md b/docs/resources/google_compute_instance_template.md index 019283365..1aa8edcad 100644 --- a/docs/resources/google_compute_instance_template.md +++ b/docs/resources/google_compute_instance_template.md @@ -60,3 +60,9 @@ Properties that can be accessed from the `google_compute_instance_template` reso * `serviceAccounts`: A list of service accounts, with their specified scopes, authorized for this instance. Only one service account per VM instance is supported. * `tags`: A list of tags to apply to this instance. Tags are used to identify valid sources or targets for network firewalls and are specified by the client during instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_instance_templates.md b/docs/resources/google_compute_instance_templates.md index ca0973ef1..6d02f7cf8 100644 --- a/docs/resources/google_compute_instance_templates.md +++ b/docs/resources/google_compute_instance_templates.md @@ -26,3 +26,7 @@ See [google_compute_instance_template.md](google_compute_instance_template.md) f ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_route.md b/docs/resources/google_compute_route.md index f1f295ee4..20428998a 100644 --- a/docs/resources/google_compute_route.md +++ b/docs/resources/google_compute_route.md @@ -45,3 +45,9 @@ Properties that can be accessed from the `google_compute_route` resource: * `next_hop_vpn_tunnel`: URL to a VpnTunnel that should handle matching packets. * `next_hop_network`: URL to a Network that should handle matching packets. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_router.md b/docs/resources/google_compute_router.md index 53fc149f7..cff38f94c 100644 --- a/docs/resources/google_compute_router.md +++ b/docs/resources/google_compute_router.md @@ -48,3 +48,9 @@ Properties that can be accessed from the `google_compute_router` resource: * `advertisedIpRanges`: User-specified list of individual IP ranges to advertise in custom mode. This field can only be populated if advertiseMode is CUSTOM and is advertised to all peers of the router. These IP ranges will be advertised in addition to any specified groups. Leave this field blank to advertise no custom IP ranges. * `region`: Region where the router resides. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_routers.md b/docs/resources/google_compute_routers.md index 7827645f5..56e203753 100644 --- a/docs/resources/google_compute_routers.md +++ b/docs/resources/google_compute_routers.md @@ -28,3 +28,7 @@ See [google_compute_router.md](google_compute_router.md) for more detailed infor ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_routes.md b/docs/resources/google_compute_routes.md index 9945b7a60..631694fbb 100644 --- a/docs/resources/google_compute_routes.md +++ b/docs/resources/google_compute_routes.md @@ -35,3 +35,7 @@ See [google_compute_route.md](google_compute_route.md) for more detailed informa ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_snapshot.md b/docs/resources/google_compute_snapshot.md index 2dfd8994f..b7504d4d8 100644 --- a/docs/resources/google_compute_snapshot.md +++ b/docs/resources/google_compute_snapshot.md @@ -57,3 +57,9 @@ Properties that can be accessed from the `google_compute_snapshot` resource: * `rawKey`: Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. * `kmsKeyName`: The name of the encryption key that is stored in Google Cloud KMS. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_snapshots.md b/docs/resources/google_compute_snapshots.md index 62e87f0d2..b05dfd20b 100644 --- a/docs/resources/google_compute_snapshots.md +++ b/docs/resources/google_compute_snapshots.md @@ -43,3 +43,7 @@ See [google_compute_snapshot.md](google_compute_snapshot.md) for more detailed i ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_ssl_certificate.md b/docs/resources/google_compute_ssl_certificate.md index 9d8084fae..f94f2e604 100644 --- a/docs/resources/google_compute_ssl_certificate.md +++ b/docs/resources/google_compute_ssl_certificate.md @@ -50,3 +50,9 @@ Properties that can be accessed from the `google_compute_ssl_certificate` resour * `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. * `private_key`: The write-only private key in PEM format. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_ssl_certificates.md b/docs/resources/google_compute_ssl_certificates.md index ab1db6bd7..6bd3a253e 100644 --- a/docs/resources/google_compute_ssl_certificates.md +++ b/docs/resources/google_compute_ssl_certificates.md @@ -47,3 +47,7 @@ See [google_compute_ssl_certificate.md](google_compute_ssl_certificate.md) for m ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_ssl_policies.md b/docs/resources/google_compute_ssl_policies.md index 191879003..de48b3d2a 100644 --- a/docs/resources/google_compute_ssl_policies.md +++ b/docs/resources/google_compute_ssl_policies.md @@ -40,3 +40,7 @@ See [google_compute_ssl_policy.md](google_compute_ssl_policy.md) for more detail ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_ssl_policy.md b/docs/resources/google_compute_ssl_policy.md index baf91eed1..54043aeb9 100644 --- a/docs/resources/google_compute_ssl_policy.md +++ b/docs/resources/google_compute_ssl_policy.md @@ -47,3 +47,9 @@ Properties that can be accessed from the `google_compute_ssl_policy` resource: * `code`: A warning code, if applicable. * `message`: A human-readable description of the warning code. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_http_proxies.md b/docs/resources/google_compute_target_http_proxies.md index f25b76af4..dd91b6254 100644 --- a/docs/resources/google_compute_target_http_proxies.md +++ b/docs/resources/google_compute_target_http_proxies.md @@ -27,3 +27,7 @@ See [google_compute_target_http_proxy.md](google_compute_target_http_proxy.md) f ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_http_proxy.md b/docs/resources/google_compute_target_http_proxy.md index 04cf987b7..7cce14ed4 100644 --- a/docs/resources/google_compute_target_http_proxy.md +++ b/docs/resources/google_compute_target_http_proxy.md @@ -31,3 +31,9 @@ Properties that can be accessed from the `google_compute_target_http_proxy` reso * `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. * `url_map`: A reference to the UrlMap resource that defines the mapping from URL to the BackendService. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_https_proxies.md b/docs/resources/google_compute_target_https_proxies.md index 72c26502d..ec709dae4 100644 --- a/docs/resources/google_compute_target_https_proxies.md +++ b/docs/resources/google_compute_target_https_proxies.md @@ -30,3 +30,7 @@ See [google_compute_target_https_proxy.md](google_compute_target_https_proxy.md) ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_https_proxy.md b/docs/resources/google_compute_target_https_proxy.md index eaecf3d4b..c51c5d649 100644 --- a/docs/resources/google_compute_target_https_proxy.md +++ b/docs/resources/google_compute_target_https_proxy.md @@ -37,3 +37,9 @@ Properties that can be accessed from the `google_compute_target_https_proxy` res * `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. * `url_map`: A reference to the UrlMap resource that defines the mapping from URL to the BackendService. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_pool.md b/docs/resources/google_compute_target_pool.md index 6b128d2b4..23ade3b15 100644 --- a/docs/resources/google_compute_target_pool.md +++ b/docs/resources/google_compute_target_pool.md @@ -41,3 +41,9 @@ Properties that can be accessed from the `google_compute_target_pool` resource: * `session_affinity`: Session affinity option. Must be one of these values: - NONE: Connections from the same client IP may go to any instance in the pool. - CLIENT_IP: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy. - CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy. * `region`: The region where the target pool resides. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_pools.md b/docs/resources/google_compute_target_pools.md index 7f24378f5..b1a3d8b3d 100644 --- a/docs/resources/google_compute_target_pools.md +++ b/docs/resources/google_compute_target_pools.md @@ -32,3 +32,7 @@ See [google_compute_target_pool.md](google_compute_target_pool.md) for more deta ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_tcp_proxies.md b/docs/resources/google_compute_target_tcp_proxies.md index 67847348d..d10ea1bb5 100644 --- a/docs/resources/google_compute_target_tcp_proxies.md +++ b/docs/resources/google_compute_target_tcp_proxies.md @@ -28,3 +28,7 @@ See [google_compute_target_tcp_proxy.md](google_compute_target_tcp_proxy.md) for ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_target_tcp_proxy.md b/docs/resources/google_compute_target_tcp_proxy.md index 7da650ee0..984e9389b 100644 --- a/docs/resources/google_compute_target_tcp_proxy.md +++ b/docs/resources/google_compute_target_tcp_proxy.md @@ -33,3 +33,9 @@ Properties that can be accessed from the `google_compute_target_tcp_proxy` resou * `proxy_header`: Specifies the type of proxy header to append before sending data to the backend, either NONE or PROXY_V1. The default is NONE. * `service`: A reference to the BackendService resource. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_url_map.md b/docs/resources/google_compute_url_map.md index 841478ee8..68c75cea4 100644 --- a/docs/resources/google_compute_url_map.md +++ b/docs/resources/google_compute_url_map.md @@ -68,3 +68,9 @@ 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. + + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_url_maps.md b/docs/resources/google_compute_url_maps.md index 9a1ddc5cc..9f98d9c4f 100644 --- a/docs/resources/google_compute_url_maps.md +++ b/docs/resources/google_compute_url_maps.md @@ -30,3 +30,7 @@ See [google_compute_url_map.md](google_compute_url_map.md) for more detailed inf ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_container_regional_cluster.md b/docs/resources/google_container_regional_cluster.md index d352cd5cb..b8734ff6a 100644 --- a/docs/resources/google_container_regional_cluster.md +++ b/docs/resources/google_container_regional_cluster.md @@ -97,3 +97,9 @@ Properties that can be accessed from the `google_container_regional_cluster` res * `expire_time`: The time the cluster will be automatically deleted in RFC3339 text format. * `location`: The location where the cluster is deployed + + + +## GCP Permissions + +Ensure the [Kubernetes Engine API](https://console.cloud.google.com/apis/library/container.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_container_regional_clusters.md b/docs/resources/google_container_regional_clusters.md index e642a91ce..6399a5378 100644 --- a/docs/resources/google_container_regional_clusters.md +++ b/docs/resources/google_container_regional_clusters.md @@ -44,3 +44,7 @@ See [google_container_regional_cluster.md](google_container_regional_cluster.md) ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Kubernetes Engine API](https://console.cloud.google.com/apis/library/container.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_dns_resource_record_set.md b/docs/resources/google_dns_resource_record_set.md index 4517c7769..61b01eda6 100644 --- a/docs/resources/google_dns_resource_record_set.md +++ b/docs/resources/google_dns_resource_record_set.md @@ -28,4 +28,10 @@ Properties that can be accessed from the `google_dns_resource_record_set` resour * `target`: As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) - * `managed_zone`: Identifies the managed zone addressed by this request. Can be the managed zone name or id. + * `managed_zone`: Identifies the managed zone addressed by this request. + + + +## GCP Permissions + +Ensure the [Google Cloud DNS API](https://console.cloud.google.com/apis/library/dns.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_dns_resource_record_sets.md b/docs/resources/google_dns_resource_record_sets.md index 1ab1eb064..b1c5dce02 100644 --- a/docs/resources/google_dns_resource_record_sets.md +++ b/docs/resources/google_dns_resource_record_sets.md @@ -30,3 +30,7 @@ See [google_dns_resource_record_set.md](google_dns_resource_record_set.md) for m ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Google Cloud DNS API](https://console.cloud.google.com/apis/library/dns.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index 5f6dae910..0386cd8f7 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -24,8 +24,18 @@ Properties that can be accessed from the `google_pubsub_subscription` resource: * `topic`: A reference to a Topic resource. + * `labels`: A set of key/value label pairs to assign to this Subscription. + * `push_config`: If push delivery is used with this subscription, this field is used to configure it. An empty pushConfig signifies that the subscriber will pull and ack messages using API methods. * `pushEndpoint`: A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use "https://example.com/push". + * `attributes`: Endpoint configuration attributes. Every endpoint has a set of API supported attributes that can be used to control different aspects of the message delivery. The currently supported attribute is x-goog-version, which you can use to change the format of the pushed message. This attribute indicates the version of the data expected by the endpoint. This controls the shape of the pushed message (i.e., its fields and metadata). The endpoint version is based on the version of the Pub/Sub API. If not present during the subscriptions.create call, it will default to the version of the API used to make such call. If not present during a subscriptions.modifyPushConfig call, its value will not be changed. subscriptions.get calls will always return a valid version, even if the subscription was created without this attribute. The possible values for this attribute are: - v1beta1: uses the push format defined in the v1beta1 Pub/Sub API. - v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API. + * `ack_deadline_seconds`: This value is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. After message delivery but before the ack deadline expires and before the message is acknowledged, it is an outstanding message and will not be delivered again during that time (on a best-effort basis). For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call subscriptions.modifyAckDeadline with the corresponding ackId if using pull. The minimum custom deadline you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds (10 minutes). If this parameter is 0, a default value of 10 seconds is used. For push delivery, this value is also used to set the request timeout for the call to the push endpoint. If the subscriber never acknowledges the message, the Pub/Sub system will eventually redeliver the message. + + + +## GCP Permissions + +Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_pubsub_subscriptions.md b/docs/resources/google_pubsub_subscriptions.md index 5bc3dba41..484986c5d 100644 --- a/docs/resources/google_pubsub_subscriptions.md +++ b/docs/resources/google_pubsub_subscriptions.md @@ -25,9 +25,14 @@ Properties that can be accessed from the `google_pubsub_subscriptions` resource: See [google_pubsub_subscription.md](google_pubsub_subscription.md) for more detailed information * `names`: an array of `google_pubsub_subscription` name * `topics`: an array of `google_pubsub_subscription` topic + * `labels`: an array of `google_pubsub_subscription` labels * `push_configs`: an array of `google_pubsub_subscription` push_config * `ack_deadline_seconds`: an array of `google_pubsub_subscription` ack_deadline_seconds ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_pubsub_topic.md b/docs/resources/google_pubsub_topic.md index 31de8cfaf..78a75b37c 100644 --- a/docs/resources/google_pubsub_topic.md +++ b/docs/resources/google_pubsub_topic.md @@ -21,3 +21,11 @@ end Properties that can be accessed from the `google_pubsub_topic` resource: * `name`: Name of the topic. + + * `labels`: A set of key/value label pairs to assign to this Topic. + + + +## GCP Permissions + +Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_pubsub_topics.md b/docs/resources/google_pubsub_topics.md index a553261b9..f33976610 100644 --- a/docs/resources/google_pubsub_topics.md +++ b/docs/resources/google_pubsub_topics.md @@ -28,7 +28,12 @@ Properties that can be accessed from the `google_pubsub_topics` resource: See [google_pubsub_topic.md](google_pubsub_topic.md) for more detailed information * `names`: an array of `google_pubsub_topic` name + * `labels`: an array of `google_pubsub_topic` labels ## Filter Criteria This resource supports all of the above properties as filter criteria, which can be used with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_sourcerepo_repositories.md b/docs/resources/google_sourcerepo_repositories.md new file mode 100644 index 000000000..31fb72978 --- /dev/null +++ b/docs/resources/google_sourcerepo_repositories.md @@ -0,0 +1,35 @@ +--- +title: About the google_sourcerepo_repositories resource +platform: gcp +--- + +## Syntax +A `google_sourcerepo_repositories` is used to test a Google Repository resource + +## Examples +``` +repo_name = 'inspec-gcp-repository' +describe.one do + google_sourcerepo_repositories(project: 'chef-gcp-inspec').names.each do |name| + describe name do + it { should match /\/repos\/#{repo_name}$/ } + end + end +end +``` + +## Properties +Properties that can be accessed from the `google_sourcerepo_repositories` resource: + +See [google_sourcerepo_repository.md](google_sourcerepo_repository.md) for more detailed information + * `names`: an array of `google_sourcerepo_repository` name + * `urls`: an array of `google_sourcerepo_repository` url + * `sizes`: an array of `google_sourcerepo_repository` size + +## Filter Criteria +This resource supports all of the above properties as filter criteria, which can be used +with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Cloud Source Repositories API](https://console.cloud.google.com/apis/library/sourcerepo.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_sourcerepo_repository.md b/docs/resources/google_sourcerepo_repository.md new file mode 100644 index 000000000..4b105c0f4 --- /dev/null +++ b/docs/resources/google_sourcerepo_repository.md @@ -0,0 +1,33 @@ +--- +title: About the google_sourcerepo_repository resource +platform: gcp +--- + +## Syntax +A `google_sourcerepo_repository` is used to test a Google Repository resource + +## Examples +``` +describe google_sourcerepo_repository(project: 'chef-gcp-inspec', name: 'inspec-gcp-repository') do + it { should exist } +end + +describe google_sourcerepo_repository(project: 'chef-gcp-inspec', name: 'nonexistent') do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_sourcerepo_repository` resource: + + * `name`: Resource name of the repository, of the form projects/{{project}}/repos/{{repo}}. The repo name may contain slashes. eg, projects/myproject/repos/name/with/slash + + * `url`: URL to clone the repository from Google Cloud Source Repositories. + + * `size`: The disk usage of the repo, in bytes. + + + +## GCP Permissions + +Ensure the [Cloud Source Repositories API](https://console.cloud.google.com/apis/library/sourcerepo.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/bigquery/property/table_encryption_configuration.rb b/libraries/google/bigquery/property/table_encryption_configuration.rb new file mode 100644 index 000000000..f7e13ae71 --- /dev/null +++ b/libraries/google/bigquery/property/table_encryption_configuration.rb @@ -0,0 +1,29 @@ +# 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 BigQuery + module Property + class TableEncryptionConfiguration + attr_reader :kms_key_name + + def initialize(args = nil) + return if args.nil? + @kms_key_name = args['kmsKeyName'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration.rb b/libraries/google/bigquery/property/table_external_data_configuration.rb new file mode 100644 index 000000000..493dc7d03 --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration.rb @@ -0,0 +1,62 @@ +# 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/bigquery/property/table_external_data_configuration_bigtable_options' +require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families' +require 'google/bigquery/property/table_external_data_configuration_csv_options' +require 'google/bigquery/property/table_external_data_configuration_google_sheets_options' +require 'google/bigquery/property/table_external_data_configuration_schema' +require 'google/bigquery/property/table_external_data_configuration_schema_fields' +module GoogleInSpec + module BigQuery + module Property + class TableExternalDataConfiguration + attr_reader :autodetect + + attr_reader :compression + + attr_reader :ignore_unknown_values + + attr_reader :max_bad_records + + attr_reader :source_format + + attr_reader :source_uris + + attr_reader :schema + + attr_reader :google_sheets_options + + attr_reader :csv_options + + attr_reader :bigtable_options + + def initialize(args = nil) + return if args.nil? + @autodetect = args['autodetect'] + @compression = args['compression'] + @ignore_unknown_values = args['ignoreUnknownValues'] + @max_bad_records = args['maxBadRecords'] + @source_format = args['sourceFormat'] + @source_uris = args['sourceUris'] + @schema = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationSchema.new(args['schema']) + @google_sheets_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationGoogleSheetsOptions.new(args['googleSheetsOptions']) + @csv_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationCsvOptions.new(args['csvOptions']) + @bigtable_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptions.new(args['bigtableOptions']) + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options.rb b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options.rb new file mode 100644 index 000000000..f5da50ab2 --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options.rb @@ -0,0 +1,36 @@ +# 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/bigquery/property/table_external_data_configuration_bigtable_options_column_families' +module GoogleInSpec + module BigQuery + module Property + class TableExternalDataConfigurationBigtableOptions + attr_reader :ignore_unspecified_column_families + + attr_reader :read_rowkey_as_string + + attr_reader :column_families + + def initialize(args = nil) + return if args.nil? + @ignore_unspecified_column_families = args['ignoreUnspecifiedColumnFamilies'] + @read_rowkey_as_string = args['readRowkeyAsString'] + @column_families = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptionsColumnFamiliesArray.parse(args['columnFamilies']) + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families.rb b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families.rb new file mode 100644 index 000000000..713f4f835 --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families.rb @@ -0,0 +1,50 @@ +# 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/bigquery/property/table_external_data_configuration_bigtable_options_column_families_columns' +module GoogleInSpec + module BigQuery + module Property + class TableExternalDataConfigurationBigtableOptionsColumnFamilies + attr_reader :columns + + attr_reader :encoding + + attr_reader :family_id + + attr_reader :only_read_latest + + attr_reader :type + + def initialize(args = nil) + return if args.nil? + @columns = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumnsArray.parse(args['columns']) + @encoding = args['encoding'] + @family_id = args['familyId'] + @only_read_latest = args['onlyReadLatest'] + @type = args['type'] + end + end + + class TableExternalDataConfigurationBigtableOptionsColumnFamiliesArray + def self.parse(value) + return if value.nil? + return TableExternalDataConfigurationBigtableOptionsColumnFamilies.new(value) unless value.is_a?(::Array) + value.map { |v| TableExternalDataConfigurationBigtableOptionsColumnFamilies.new(v) } + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families_columns.rb b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families_columns.rb new file mode 100644 index 000000000..9869d4692 --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_bigtable_options_column_families_columns.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 BigQuery + module Property + class TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns + attr_reader :encoding + + attr_reader :field_name + + attr_reader :only_read_latest + + attr_reader :qualifier_string + + attr_reader :type + + def initialize(args = nil) + return if args.nil? + @encoding = args['encoding'] + @field_name = args['fieldName'] + @only_read_latest = args['onlyReadLatest'] + @qualifier_string = args['qualifierString'] + @type = args['type'] + end + end + + class TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumnsArray + def self.parse(value) + return if value.nil? + return TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns.new(value) unless value.is_a?(::Array) + value.map { |v| TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns.new(v) } + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_csv_options.rb b/libraries/google/bigquery/property/table_external_data_configuration_csv_options.rb new file mode 100644 index 000000000..9620948aa --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_csv_options.rb @@ -0,0 +1,44 @@ +# 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 BigQuery + module Property + class TableExternalDataConfigurationCsvOptions + attr_reader :allow_jagged_rows + + attr_reader :allow_quoted_newlines + + attr_reader :encoding + + attr_reader :field_delimiter + + attr_reader :quote + + attr_reader :skip_leading_rows + + def initialize(args = nil) + return if args.nil? + @allow_jagged_rows = args['allowJaggedRows'] + @allow_quoted_newlines = args['allowQuotedNewlines'] + @encoding = args['encoding'] + @field_delimiter = args['fieldDelimiter'] + @quote = args['quote'] + @skip_leading_rows = args['skipLeadingRows'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_google_sheets_options.rb b/libraries/google/bigquery/property/table_external_data_configuration_google_sheets_options.rb new file mode 100644 index 000000000..1833dbba8 --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_google_sheets_options.rb @@ -0,0 +1,29 @@ +# 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 BigQuery + module Property + class TableExternalDataConfigurationGoogleSheetsOptions + attr_reader :skip_leading_rows + + def initialize(args = nil) + return if args.nil? + @skip_leading_rows = args['skipLeadingRows'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_schema.rb b/libraries/google/bigquery/property/table_external_data_configuration_schema.rb new file mode 100644 index 000000000..6ef8eef8d --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_schema.rb @@ -0,0 +1,30 @@ +# 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/bigquery/property/table_external_data_configuration_schema_fields' +module GoogleInSpec + module BigQuery + module Property + class TableExternalDataConfigurationSchema + attr_reader :fields + + def initialize(args = nil) + return if args.nil? + @fields = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationSchemaFieldsArray.parse(args['fields']) + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_external_data_configuration_schema_fields.rb b/libraries/google/bigquery/property/table_external_data_configuration_schema_fields.rb new file mode 100644 index 000000000..c2990b4ae --- /dev/null +++ b/libraries/google/bigquery/property/table_external_data_configuration_schema_fields.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 BigQuery + module Property + class TableExternalDataConfigurationSchemaFields + attr_reader :description + + attr_reader :fields + + attr_reader :mode + + attr_reader :name + + attr_reader :type + + def initialize(args = nil) + return if args.nil? + @description = args['description'] + @fields = args['fields'] + @mode = args['mode'] + @name = args['name'] + @type = args['type'] + end + end + + class TableExternalDataConfigurationSchemaFieldsArray + def self.parse(value) + return if value.nil? + return TableExternalDataConfigurationSchemaFields.new(value) unless value.is_a?(::Array) + value.map { |v| TableExternalDataConfigurationSchemaFields.new(v) } + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_schema.rb b/libraries/google/bigquery/property/table_schema.rb new file mode 100644 index 000000000..79fa4940d --- /dev/null +++ b/libraries/google/bigquery/property/table_schema.rb @@ -0,0 +1,30 @@ +# 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/bigquery/property/table_schema_fields' +module GoogleInSpec + module BigQuery + module Property + class TableSchema + attr_reader :fields + + def initialize(args = nil) + return if args.nil? + @fields = GoogleInSpec::BigQuery::Property::TableSchemaFieldsArray.parse(args['fields']) + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_schema_fields.rb b/libraries/google/bigquery/property/table_schema_fields.rb new file mode 100644 index 000000000..62bf7298c --- /dev/null +++ b/libraries/google/bigquery/property/table_schema_fields.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 BigQuery + module Property + class TableSchemaFields + attr_reader :description + + attr_reader :fields + + attr_reader :mode + + attr_reader :name + + attr_reader :type + + def initialize(args = nil) + return if args.nil? + @description = args['description'] + @fields = args['fields'] + @mode = args['mode'] + @name = args['name'] + @type = args['type'] + end + end + + class TableSchemaFieldsArray + def self.parse(value) + return if value.nil? + return TableSchemaFields.new(value) unless value.is_a?(::Array) + value.map { |v| TableSchemaFields.new(v) } + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_streaming_buffer.rb b/libraries/google/bigquery/property/table_streaming_buffer.rb new file mode 100644 index 000000000..a38f90ba3 --- /dev/null +++ b/libraries/google/bigquery/property/table_streaming_buffer.rb @@ -0,0 +1,35 @@ +# 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 BigQuery + module Property + class TableStreamingBuffer + attr_reader :estimated_bytes + + attr_reader :estimated_rows + + attr_reader :oldest_entry_time + + def initialize(args = nil) + return if args.nil? + @estimated_bytes = args['estimatedBytes'] + @estimated_rows = args['estimatedRows'] + @oldest_entry_time = args['oldestEntryTime'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_table_reference.rb b/libraries/google/bigquery/property/table_table_reference.rb new file mode 100644 index 000000000..43cdb0060 --- /dev/null +++ b/libraries/google/bigquery/property/table_table_reference.rb @@ -0,0 +1,35 @@ +# 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 BigQuery + module Property + class TableTableReference + attr_reader :dataset_id + + attr_reader :project_id + + attr_reader :table_id + + def initialize(args = nil) + return if args.nil? + @dataset_id = args['datasetId'] + @project_id = args['projectId'] + @table_id = args['tableId'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_time_partitioning.rb b/libraries/google/bigquery/property/table_time_partitioning.rb new file mode 100644 index 000000000..24f2e0b65 --- /dev/null +++ b/libraries/google/bigquery/property/table_time_partitioning.rb @@ -0,0 +1,32 @@ +# 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 BigQuery + module Property + class TableTimePartitioning + attr_reader :expiration_ms + + attr_reader :type + + def initialize(args = nil) + return if args.nil? + @expiration_ms = args['expirationMs'] + @type = args['type'] + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_view.rb b/libraries/google/bigquery/property/table_view.rb new file mode 100644 index 000000000..c263d4f7d --- /dev/null +++ b/libraries/google/bigquery/property/table_view.rb @@ -0,0 +1,33 @@ +# 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/bigquery/property/table_view_user_defined_function_resources' +module GoogleInSpec + module BigQuery + module Property + class TableView + attr_reader :use_legacy_sql + + attr_reader :user_defined_function_resources + + def initialize(args = nil) + return if args.nil? + @use_legacy_sql = args['useLegacySql'] + @user_defined_function_resources = GoogleInSpec::BigQuery::Property::TableViewUserDefinedFunctionResourcesArray.parse(args['userDefinedFunctionResources']) + end + end + end + end +end diff --git a/libraries/google/bigquery/property/table_view_user_defined_function_resources.rb b/libraries/google/bigquery/property/table_view_user_defined_function_resources.rb new file mode 100644 index 000000000..c44403a25 --- /dev/null +++ b/libraries/google/bigquery/property/table_view_user_defined_function_resources.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 BigQuery + module Property + class TableViewUserDefinedFunctionResources + attr_reader :inline_code + + attr_reader :resource_uri + + def initialize(args = nil) + return if args.nil? + @inline_code = args['inlineCode'] + @resource_uri = args['resourceUri'] + end + end + + class TableViewUserDefinedFunctionResourcesArray + def self.parse(value) + return if value.nil? + return TableViewUserDefinedFunctionResources.new(value) unless value.is_a?(::Array) + value.map { |v| TableViewUserDefinedFunctionResources.new(v) } + end + end + end + end +end diff --git a/libraries/google/pubsub/property/subscription_push_config.rb b/libraries/google/pubsub/property/subscription_push_config.rb index 90695d1e6..22a06e45b 100644 --- a/libraries/google/pubsub/property/subscription_push_config.rb +++ b/libraries/google/pubsub/property/subscription_push_config.rb @@ -19,9 +19,12 @@ module Property class SubscriptionPushConfig attr_reader :push_endpoint + attr_reader :attributes + def initialize(args = nil) return if args.nil? @push_endpoint = args['pushEndpoint'] + @attributes = args['attributes'] end end end diff --git a/libraries/google_bigquery_dataset.rb b/libraries/google_bigquery_dataset.rb index cfd684f7c..452a91180 100644 --- a/libraries/google_bigquery_dataset.rb +++ b/libraries/google_bigquery_dataset.rb @@ -17,7 +17,7 @@ require 'google/bigquery/property/dataset_access' require 'google/bigquery/property/dataset_dataset_reference' -# A provider to manage Google Cloud BigQuery resources. +# A provider to manage BigQuery resources. class Dataset < GcpResourceBase name 'google_bigquery_dataset' desc 'Dataset' @@ -34,17 +34,10 @@ class Dataset < GcpResourceBase attr_reader :labels attr_reader :last_modified_time attr_reader :location - def base - 'https://www.googleapis.com/bigquery/v2/' - end - - def url - 'projects/{{project}}/datasets/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -70,4 +63,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/bigquery/v2/' + end + + def resource_base_url + 'projects/{{project}}/datasets/{{name}}' + end end diff --git a/libraries/google_bigquery_datasets.rb b/libraries/google_bigquery_datasets.rb index 3d2163c05..ce0cb3f0f 100644 --- a/libraries/google_bigquery_datasets.rb +++ b/libraries/google_bigquery_datasets.rb @@ -31,14 +31,6 @@ class Datasets < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/bigquery/v2/' - end - - def url - 'projects/{{project}}/datasets' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -47,7 +39,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -87,4 +79,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/bigquery/v2/' + end + + def resource_base_url + 'projects/{{project}}/datasets' + end end diff --git a/libraries/google_bigquery_table.rb b/libraries/google_bigquery_table.rb new file mode 100644 index 000000000..1adfa2c5e --- /dev/null +++ b/libraries/google_bigquery_table.rb @@ -0,0 +1,109 @@ +# 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/bigquery/property/table_encryption_configuration' +require 'google/bigquery/property/table_external_data_configuration' +require 'google/bigquery/property/table_external_data_configuration_bigtable_options' +require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families' +require 'google/bigquery/property/table_external_data_configuration_csv_options' +require 'google/bigquery/property/table_external_data_configuration_google_sheets_options' +require 'google/bigquery/property/table_external_data_configuration_schema' +require 'google/bigquery/property/table_external_data_configuration_schema_fields' +require 'google/bigquery/property/table_schema' +require 'google/bigquery/property/table_schema_fields' +require 'google/bigquery/property/table_streaming_buffer' +require 'google/bigquery/property/table_table_reference' +require 'google/bigquery/property/table_time_partitioning' +require 'google/bigquery/property/table_view' +require 'google/bigquery/property/table_view_user_defined_function_resources' + +# A provider to manage BigQuery resources. +class Table < GcpResourceBase + name 'google_bigquery_table' + desc 'Table' + supports platform: 'gcp' + + attr_reader :table_reference + attr_reader :creation_time + attr_reader :description + attr_reader :friendly_name + attr_reader :id + attr_reader :labels + attr_reader :last_modified_time + attr_reader :location + attr_reader :name + attr_reader :num_bytes + attr_reader :num_long_term_bytes + attr_reader :num_rows + attr_reader :type + attr_reader :view + attr_reader :time_partitioning + attr_reader :streaming_buffer + attr_reader :schema + attr_reader :encryption_configuration + attr_reader :expiration_time + attr_reader :external_data_configuration + attr_reader :dataset + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @fetched = @connection.fetch(product_url, resource_base_url, params) + parse unless @fetched.nil? + end + + def parse + @table_reference = GoogleInSpec::BigQuery::Property::TableTableReference.new(@fetched['tableReference']) + @creation_time = @fetched['creationTime'] + @description = @fetched['description'] + @friendly_name = @fetched['friendlyName'] + @id = @fetched['id'] + @labels = @fetched['labels'] + @last_modified_time = @fetched['lastModifiedTime'] + @location = @fetched['location'] + @name = @fetched['name'] + @num_bytes = @fetched['numBytes'] + @num_long_term_bytes = @fetched['numLongTermBytes'] + @num_rows = @fetched['numRows'] + @type = @fetched['type'] + @view = GoogleInSpec::BigQuery::Property::TableView.new(@fetched['view']) + @time_partitioning = GoogleInSpec::BigQuery::Property::TableTimePartitioning.new(@fetched['timePartitioning']) + @streaming_buffer = GoogleInSpec::BigQuery::Property::TableStreamingBuffer.new(@fetched['streamingBuffer']) + @schema = GoogleInSpec::BigQuery::Property::TableSchema.new(@fetched['schema']) + @encryption_configuration = GoogleInSpec::BigQuery::Property::TableEncryptionConfiguration.new(@fetched['encryptionConfiguration']) + @expiration_time = @fetched['expirationTime'] + @external_data_configuration = GoogleInSpec::BigQuery::Property::TableExternalDataConfiguration.new(@fetched['externalDataConfiguration']) + @dataset = @fetched['dataset'] + 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 + + private + + def product_url + 'https://www.googleapis.com/bigquery/v2/' + end + + def resource_base_url + 'projects/{{project}}/datasets/{{dataset}}/tables/{{name}}' + end +end diff --git a/libraries/google_bigquery_tables.rb b/libraries/google_bigquery_tables.rb new file mode 100644 index 000000000..b07711419 --- /dev/null +++ b/libraries/google_bigquery_tables.rb @@ -0,0 +1,120 @@ +# 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 Tables < GcpResourceBase + name 'google_bigquery_tables' + desc 'Table plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:table_references, field: :table_reference) + filter_table_config.add(:creation_times, field: :creation_time) + filter_table_config.add(:friendly_names, field: :friendly_name) + filter_table_config.add(:ids, field: :id) + filter_table_config.add(:labels, field: :labels) + filter_table_config.add(:last_modified_times, field: :last_modified_time) + filter_table_config.add(:locations, field: :location) + filter_table_config.add(:num_bytes, field: :num_bytes) + filter_table_config.add(:num_long_term_bytes, field: :num_long_term_bytes) + filter_table_config.add(:num_rows, field: :num_rows) + filter_table_config.add(:types, field: :type) + filter_table_config.add(:views, field: :view) + filter_table_config.add(:time_partitionings, field: :time_partitioning) + filter_table_config.add(:streaming_buffers, field: :streaming_buffer) + filter_table_config.add(:schemas, field: :schema) + filter_table_config.add(:encryption_configurations, field: :encryption_configuration) + filter_table_config.add(:expiration_times, field: :expiration_time) + filter_table_config.add(:external_data_configurations, field: :external_data_configuration) + filter_table_config.add(:datasets, field: :dataset) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('tables') + 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) + 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 + { + 'tableReference' => ->(obj) { return :table_reference, GoogleInSpec::BigQuery::Property::TableTableReference.new(obj['tableReference']) }, + 'creationTime' => ->(obj) { return :creation_time, obj['creationTime'] }, + 'friendlyName' => ->(obj) { return :friendly_name, obj['friendlyName'] }, + 'id' => ->(obj) { return :id, obj['id'] }, + 'labels' => ->(obj) { return :labels, obj['labels'] }, + 'lastModifiedTime' => ->(obj) { return :last_modified_time, obj['lastModifiedTime'] }, + 'location' => ->(obj) { return :location, obj['location'] }, + 'numBytes' => ->(obj) { return :num_bytes, obj['numBytes'] }, + 'numLongTermBytes' => ->(obj) { return :num_long_term_bytes, obj['numLongTermBytes'] }, + 'numRows' => ->(obj) { return :num_rows, obj['numRows'] }, + 'type' => ->(obj) { return :type, obj['type'] }, + 'view' => ->(obj) { return :view, GoogleInSpec::BigQuery::Property::TableView.new(obj['view']) }, + 'timePartitioning' => ->(obj) { return :time_partitioning, GoogleInSpec::BigQuery::Property::TableTimePartitioning.new(obj['timePartitioning']) }, + 'streamingBuffer' => ->(obj) { return :streaming_buffer, GoogleInSpec::BigQuery::Property::TableStreamingBuffer.new(obj['streamingBuffer']) }, + 'schema' => ->(obj) { return :schema, GoogleInSpec::BigQuery::Property::TableSchema.new(obj['schema']) }, + 'encryptionConfiguration' => ->(obj) { return :encryption_configuration, GoogleInSpec::BigQuery::Property::TableEncryptionConfiguration.new(obj['encryptionConfiguration']) }, + 'expirationTime' => ->(obj) { return :expiration_time, obj['expirationTime'] }, + 'externalDataConfiguration' => ->(obj) { return :external_data_configuration, GoogleInSpec::BigQuery::Property::TableExternalDataConfiguration.new(obj['externalDataConfiguration']) }, + 'dataset' => ->(obj) { return :dataset, obj['dataset'] }, + } + 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://www.googleapis.com/bigquery/v2/' + end + + def resource_base_url + 'projects/{{project}}/datasets/{{dataset}}/tables' + end +end diff --git a/libraries/google_cloudbuild_trigger.rb b/libraries/google_cloudbuild_trigger.rb index c99e5a2f7..071af6f7c 100644 --- a/libraries/google_cloudbuild_trigger.rb +++ b/libraries/google_cloudbuild_trigger.rb @@ -18,7 +18,7 @@ require 'google/cloudbuild/property/trigger_build_steps' require 'google/cloudbuild/property/trigger_trigger_template' -# A provider to manage Cloud build resources. +# A provider to manage Cloud Build resources. class Trigger < GcpResourceBase name 'google_cloudbuild_trigger' desc 'Trigger' @@ -34,17 +34,10 @@ class Trigger < GcpResourceBase attr_reader :included_files attr_reader :trigger_template attr_reader :build - def base - 'https://cloudbuild.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/triggers/{{id}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -69,4 +62,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://cloudbuild.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/triggers/{{id}}' + end end diff --git a/libraries/google_cloudbuild_triggers.rb b/libraries/google_cloudbuild_triggers.rb index b8221c647..55abd90f0 100644 --- a/libraries/google_cloudbuild_triggers.rb +++ b/libraries/google_cloudbuild_triggers.rb @@ -36,14 +36,6 @@ class Triggers < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://cloudbuild.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/triggers' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -52,7 +44,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -97,4 +89,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://cloudbuild.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/triggers' + end end diff --git a/libraries/google_compute_autoscaler.rb b/libraries/google_compute_autoscaler.rb index c7019072c..ea2b7beb3 100644 --- a/libraries/google_compute_autoscaler.rb +++ b/libraries/google_compute_autoscaler.rb @@ -19,7 +19,7 @@ require 'google/compute/property/autoscaler_autoscaling_policy_custom_metric_utilizations' require 'google/compute/property/autoscaler_autoscaling_policy_load_balancing_utilization' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class Autoscaler < GcpResourceBase name 'google_compute_autoscaler' desc 'Autoscaler' @@ -32,17 +32,10 @@ class Autoscaler < GcpResourceBase attr_reader :autoscaling_policy attr_reader :target attr_reader :zone - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/autoscalers/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -64,4 +57,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/autoscalers/{{name}}' + end end diff --git a/libraries/google_compute_autoscalers.rb b/libraries/google_compute_autoscalers.rb index ce7954895..e8ee98935 100644 --- a/libraries/google_compute_autoscalers.rb +++ b/libraries/google_compute_autoscalers.rb @@ -33,14 +33,6 @@ class Autoscalers < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/autoscalers' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -49,7 +41,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -91,4 +83,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/autoscalers' + end end diff --git a/libraries/google_compute_backend_service.rb b/libraries/google_compute_backend_service.rb index b4e6c8ef6..14ddf6dda 100644 --- a/libraries/google_compute_backend_service.rb +++ b/libraries/google_compute_backend_service.rb @@ -20,7 +20,7 @@ require 'google/compute/property/backendservice_connection_draining' require 'google/compute/property/backendservice_iap' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class BackendService < GcpResourceBase name 'google_compute_backend_service' desc 'BackendService' @@ -43,17 +43,10 @@ class BackendService < GcpResourceBase attr_reader :region attr_reader :session_affinity attr_reader :timeout_sec - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/backendServices/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -85,4 +78,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/backendServices/{{name}}' + end end diff --git a/libraries/google_compute_backend_services.rb b/libraries/google_compute_backend_services.rb index 8daa82066..c98a3ad99 100644 --- a/libraries/google_compute_backend_services.rb +++ b/libraries/google_compute_backend_services.rb @@ -43,14 +43,6 @@ class BackendServices < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/backendServices' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -59,7 +51,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -111,4 +103,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/backendServices' + end end diff --git a/libraries/google_compute_disk.rb b/libraries/google_compute_disk.rb index caa586125..9dae4cc58 100644 --- a/libraries/google_compute_disk.rb +++ b/libraries/google_compute_disk.rb @@ -18,7 +18,7 @@ require 'google/compute/property/disk_source_image_encryption_key' require 'google/compute/property/disk_source_snapshot_encryption_key' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class Disk < GcpResourceBase name 'google_compute_disk' desc 'Disk' @@ -44,17 +44,10 @@ class Disk < GcpResourceBase attr_reader :source_snapshot attr_reader :source_snapshot_encryption_key attr_reader :source_snapshot_id - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/disks/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -89,4 +82,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/disks/{{name}}' + end end diff --git a/libraries/google_compute_disks.rb b/libraries/google_compute_disks.rb index cb3bf974d..ece34ca12 100644 --- a/libraries/google_compute_disks.rb +++ b/libraries/google_compute_disks.rb @@ -46,14 +46,6 @@ class Disks < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/disks' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -62,7 +54,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -117,4 +109,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/disks' + end end diff --git a/libraries/google_compute_global_address.rb b/libraries/google_compute_global_address.rb index 43da4d631..c312b2386 100644 --- a/libraries/google_compute_global_address.rb +++ b/libraries/google_compute_global_address.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class GlobalAddress < GcpResourceBase name 'google_compute_global_address' desc 'GlobalAddress' @@ -29,17 +29,10 @@ class GlobalAddress < GcpResourceBase attr_reader :ip_version attr_reader :region attr_reader :address_type - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/addresses/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -62,4 +55,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/addresses/{{name}}' + end end diff --git a/libraries/google_compute_global_addresses.rb b/libraries/google_compute_global_addresses.rb index 34f7eff0c..c49ab869c 100644 --- a/libraries/google_compute_global_addresses.rb +++ b/libraries/google_compute_global_addresses.rb @@ -34,14 +34,6 @@ class GlobalAddresss < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/addresses' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -50,7 +42,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -93,4 +85,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/addresses' + end end diff --git a/libraries/google_compute_global_forwarding_rule.rb b/libraries/google_compute_global_forwarding_rule.rb index 27d1b7ce1..0f48e1ff6 100644 --- a/libraries/google_compute_global_forwarding_rule.rb +++ b/libraries/google_compute_global_forwarding_rule.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class GlobalForwardingRule < GcpResourceBase name 'google_compute_global_forwarding_rule' desc 'GlobalForwardingRule' @@ -36,17 +36,10 @@ class GlobalForwardingRule < GcpResourceBase attr_reader :subnetwork attr_reader :region attr_reader :target - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/forwardingRules/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -76,4 +69,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/forwardingRules/{{name}}' + end end diff --git a/libraries/google_compute_global_forwarding_rules.rb b/libraries/google_compute_global_forwarding_rules.rb index 9f2f8f3a5..4edce1357 100644 --- a/libraries/google_compute_global_forwarding_rules.rb +++ b/libraries/google_compute_global_forwarding_rules.rb @@ -41,14 +41,6 @@ class GlobalForwardingRules < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/forwardingRules' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -57,7 +49,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -107,4 +99,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/forwardingRules' + end end diff --git a/libraries/google_compute_health_check.rb b/libraries/google_compute_health_check.rb index 47c42ecfa..478477c58 100644 --- a/libraries/google_compute_health_check.rb +++ b/libraries/google_compute_health_check.rb @@ -19,7 +19,7 @@ require 'google/compute/property/healthcheck_ssl_health_check' require 'google/compute/property/healthcheck_tcp_health_check' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class HealthCheck < GcpResourceBase name 'google_compute_health_check' desc 'HealthCheck' @@ -38,17 +38,10 @@ class HealthCheck < GcpResourceBase attr_reader :https_health_check attr_reader :tcp_health_check attr_reader :ssl_health_check - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/healthChecks/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -76,4 +69,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/healthChecks/{{name}}' + end end diff --git a/libraries/google_compute_health_checks.rb b/libraries/google_compute_health_checks.rb index 0ef54fba3..2f0492165 100644 --- a/libraries/google_compute_health_checks.rb +++ b/libraries/google_compute_health_checks.rb @@ -39,14 +39,6 @@ class HealthChecks < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/healthChecks' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -55,7 +47,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -103,4 +95,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/healthChecks' + end end diff --git a/libraries/google_compute_http_health_check.rb b/libraries/google_compute_http_health_check.rb index 55136b30e..caa340629 100644 --- a/libraries/google_compute_http_health_check.rb +++ b/libraries/google_compute_http_health_check.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class HttpHealthCheck < GcpResourceBase name 'google_compute_http_health_check' desc 'HttpHealthCheck' @@ -32,17 +32,10 @@ class HttpHealthCheck < GcpResourceBase attr_reader :request_path attr_reader :timeout_sec attr_reader :unhealthy_threshold - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/httpHealthChecks/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -68,4 +61,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/httpHealthChecks/{{name}}' + end end diff --git a/libraries/google_compute_http_health_checks.rb b/libraries/google_compute_http_health_checks.rb index d313de253..64c5a6c81 100644 --- a/libraries/google_compute_http_health_checks.rb +++ b/libraries/google_compute_http_health_checks.rb @@ -37,14 +37,6 @@ class HttpHealthChecks < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/httpHealthChecks' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -53,7 +45,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -99,4 +91,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/httpHealthChecks' + end end diff --git a/libraries/google_compute_https_health_check.rb b/libraries/google_compute_https_health_check.rb index 104278916..fa27b9dae 100644 --- a/libraries/google_compute_https_health_check.rb +++ b/libraries/google_compute_https_health_check.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class HttpsHealthCheck < GcpResourceBase name 'google_compute_https_health_check' desc 'HttpsHealthCheck' @@ -32,17 +32,10 @@ class HttpsHealthCheck < GcpResourceBase attr_reader :request_path attr_reader :timeout_sec attr_reader :unhealthy_threshold - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/httpsHealthChecks/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -68,4 +61,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/httpsHealthChecks/{{name}}' + end end diff --git a/libraries/google_compute_https_health_checks.rb b/libraries/google_compute_https_health_checks.rb index dc4fa7907..8576ef71c 100644 --- a/libraries/google_compute_https_health_checks.rb +++ b/libraries/google_compute_https_health_checks.rb @@ -37,14 +37,6 @@ class HttpsHealthChecks < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/httpsHealthChecks' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -53,7 +45,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -99,4 +91,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/httpsHealthChecks' + end end diff --git a/libraries/google_compute_instance_group_manager.rb b/libraries/google_compute_instance_group_manager.rb index f518ff84f..c0d213ea8 100644 --- a/libraries/google_compute_instance_group_manager.rb +++ b/libraries/google_compute_instance_group_manager.rb @@ -17,7 +17,7 @@ require 'google/compute/property/instancegroupmanager_current_actions' require 'google/compute/property/instancegroupmanager_named_ports' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class InstanceGroupManager < GcpResourceBase name 'google_compute_instance_group_manager' desc 'InstanceGroupManager' @@ -36,17 +36,10 @@ class InstanceGroupManager < GcpResourceBase attr_reader :target_pools attr_reader :target_size attr_reader :zone - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -74,4 +67,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}' + end end diff --git a/libraries/google_compute_instance_group_managers.rb b/libraries/google_compute_instance_group_managers.rb index 616853fc7..332e204c4 100644 --- a/libraries/google_compute_instance_group_managers.rb +++ b/libraries/google_compute_instance_group_managers.rb @@ -39,14 +39,6 @@ class InstanceGroupManagers < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -55,7 +47,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -103,4 +95,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/zones/{{zone}}/instanceGroupManagers' + end end diff --git a/libraries/google_compute_instance_template.rb b/libraries/google_compute_instance_template.rb index 86c352fb9..2dea96d2d 100644 --- a/libraries/google_compute_instance_template.rb +++ b/libraries/google_compute_instance_template.rb @@ -22,7 +22,7 @@ require 'google/compute/property/instancetemplate_properties_service_accounts' require 'google/compute/property/instancetemplate_properties_tags' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class InstanceTemplate < GcpResourceBase name 'google_compute_instance_template' desc 'InstanceTemplate' @@ -33,17 +33,10 @@ class InstanceTemplate < GcpResourceBase attr_reader :id attr_reader :name attr_reader :properties - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/instanceTemplates/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -63,4 +56,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/instanceTemplates/{{name}}' + end end diff --git a/libraries/google_compute_instance_templates.rb b/libraries/google_compute_instance_templates.rb index bd5248bc6..4ae92b1b0 100644 --- a/libraries/google_compute_instance_templates.rb +++ b/libraries/google_compute_instance_templates.rb @@ -31,14 +31,6 @@ class InstanceTemplates < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/instanceTemplates' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -47,7 +39,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -87,4 +79,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/instanceTemplates' + end end diff --git a/libraries/google_compute_route.rb b/libraries/google_compute_route.rb index 27da100a3..6542eb6cb 100644 --- a/libraries/google_compute_route.rb +++ b/libraries/google_compute_route.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class Route < GcpResourceBase name 'google_compute_route' desc 'Route' @@ -32,17 +32,10 @@ class Route < GcpResourceBase attr_reader :next_hop_ip attr_reader :next_hop_vpn_tunnel attr_reader :next_hop_network - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/routes/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -68,4 +61,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/routes/{{name}}' + end end diff --git a/libraries/google_compute_router.rb b/libraries/google_compute_router.rb index e39217ee4..34e9c64b3 100644 --- a/libraries/google_compute_router.rb +++ b/libraries/google_compute_router.rb @@ -17,7 +17,7 @@ require 'google/compute/property/router_bgp' require 'google/compute/property/router_bgp_advertised_ip_ranges' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class Router < GcpResourceBase name 'google_compute_router' desc 'Router' @@ -30,17 +30,10 @@ class Router < GcpResourceBase attr_reader :network attr_reader :bgp attr_reader :region - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/regions/{{region}}/routers/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -62,4 +55,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/routers/{{name}}' + end end diff --git a/libraries/google_compute_routers.rb b/libraries/google_compute_routers.rb index 4254b22cc..0a060f1b5 100644 --- a/libraries/google_compute_routers.rb +++ b/libraries/google_compute_routers.rb @@ -33,14 +33,6 @@ class Routers < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/regions/{{region}}/routers' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -49,7 +41,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -91,4 +83,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/routers' + end end diff --git a/libraries/google_compute_routes.rb b/libraries/google_compute_routes.rb index af08fcf63..34446a7d4 100644 --- a/libraries/google_compute_routes.rb +++ b/libraries/google_compute_routes.rb @@ -37,14 +37,6 @@ class Routes < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/routes' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -53,7 +45,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -99,4 +91,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/routes' + end end diff --git a/libraries/google_compute_snapshot.rb b/libraries/google_compute_snapshot.rb index 482121e07..c1251db35 100644 --- a/libraries/google_compute_snapshot.rb +++ b/libraries/google_compute_snapshot.rb @@ -17,7 +17,7 @@ require 'google/compute/property/snapshot_snapshot_encryption_key' require 'google/compute/property/snapshot_source_disk_encryption_key' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class Snapshot < GcpResourceBase name 'google_compute_snapshot' desc 'Snapshot' @@ -36,17 +36,10 @@ class Snapshot < GcpResourceBase attr_reader :zone attr_reader :snapshot_encryption_key attr_reader :source_disk_encryption_key - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/snapshots/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -74,4 +67,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/snapshots/{{name}}' + end end diff --git a/libraries/google_compute_snapshots.rb b/libraries/google_compute_snapshots.rb index 675d660e5..eeb00ebdb 100644 --- a/libraries/google_compute_snapshots.rb +++ b/libraries/google_compute_snapshots.rb @@ -39,14 +39,6 @@ class Snapshots < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/snapshots' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -55,7 +47,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -103,4 +95,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/snapshots' + end end diff --git a/libraries/google_compute_ssl_certificate.rb b/libraries/google_compute_ssl_certificate.rb index 6dbcdff93..081e4b6cd 100644 --- a/libraries/google_compute_ssl_certificate.rb +++ b/libraries/google_compute_ssl_certificate.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class SslCertificate < GcpResourceBase name 'google_compute_ssl_certificate' desc 'SslCertificate' @@ -27,17 +27,10 @@ class SslCertificate < GcpResourceBase attr_reader :id attr_reader :name attr_reader :private_key - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/sslCertificates/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -58,4 +51,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/sslCertificates/{{name}}' + end end diff --git a/libraries/google_compute_ssl_certificates.rb b/libraries/google_compute_ssl_certificates.rb index 0cb922ce1..ba3d09b9c 100644 --- a/libraries/google_compute_ssl_certificates.rb +++ b/libraries/google_compute_ssl_certificates.rb @@ -32,14 +32,6 @@ class SslCertificates < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/sslCertificates' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -48,7 +40,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -89,4 +81,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/sslCertificates' + end end diff --git a/libraries/google_compute_ssl_policies.rb b/libraries/google_compute_ssl_policies.rb index c1175286b..736616a57 100644 --- a/libraries/google_compute_ssl_policies.rb +++ b/libraries/google_compute_ssl_policies.rb @@ -36,14 +36,6 @@ class SslPolicys < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/sslPolicies' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -52,7 +44,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -97,4 +89,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/sslPolicies' + end end diff --git a/libraries/google_compute_ssl_policy.rb b/libraries/google_compute_ssl_policy.rb index ee061c5b9..a5dadec6e 100644 --- a/libraries/google_compute_ssl_policy.rb +++ b/libraries/google_compute_ssl_policy.rb @@ -16,7 +16,7 @@ require 'gcp_backend' require 'google/compute/property/sslpolicy_warnings' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class SslPolicy < GcpResourceBase name 'google_compute_ssl_policy' desc 'SslPolicy' @@ -32,17 +32,10 @@ class SslPolicy < GcpResourceBase attr_reader :custom_features attr_reader :fingerprint attr_reader :warnings - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/sslPolicies/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -67,4 +60,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/sslPolicies/{{name}}' + end end diff --git a/libraries/google_compute_target_http_proxies.rb b/libraries/google_compute_target_http_proxies.rb index 956e5b13b..4e10faf98 100644 --- a/libraries/google_compute_target_http_proxies.rb +++ b/libraries/google_compute_target_http_proxies.rb @@ -31,14 +31,6 @@ class TargetHttpProxys < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetHttpProxies' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -47,7 +39,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -87,4 +79,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetHttpProxies' + end end diff --git a/libraries/google_compute_target_http_proxy.rb b/libraries/google_compute_target_http_proxy.rb index 54bd90cda..1bd781656 100644 --- a/libraries/google_compute_target_http_proxy.rb +++ b/libraries/google_compute_target_http_proxy.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class TargetHttpProxy < GcpResourceBase name 'google_compute_target_http_proxy' desc 'TargetHttpProxy' @@ -26,17 +26,10 @@ class TargetHttpProxy < GcpResourceBase attr_reader :id attr_reader :name attr_reader :url_map - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetHttpProxies/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -56,4 +49,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetHttpProxies/{{name}}' + end end diff --git a/libraries/google_compute_target_https_proxies.rb b/libraries/google_compute_target_https_proxies.rb index b55270214..beb420b38 100644 --- a/libraries/google_compute_target_https_proxies.rb +++ b/libraries/google_compute_target_https_proxies.rb @@ -34,14 +34,6 @@ class TargetHttpsProxys < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetHttpsProxies' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -50,7 +42,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -93,4 +85,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetHttpsProxies' + end end diff --git a/libraries/google_compute_target_https_proxy.rb b/libraries/google_compute_target_https_proxy.rb index a7a13378d..41c9c55ee 100644 --- a/libraries/google_compute_target_https_proxy.rb +++ b/libraries/google_compute_target_https_proxy.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class TargetHttpsProxy < GcpResourceBase name 'google_compute_target_https_proxy' desc 'TargetHttpsProxy' @@ -29,17 +29,10 @@ class TargetHttpsProxy < GcpResourceBase attr_reader :ssl_certificates attr_reader :ssl_policy attr_reader :url_map - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetHttpsProxies/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -62,4 +55,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetHttpsProxies/{{name}}' + end end diff --git a/libraries/google_compute_target_pool.rb b/libraries/google_compute_target_pool.rb index e589c1eda..a20d4e85c 100644 --- a/libraries/google_compute_target_pool.rb +++ b/libraries/google_compute_target_pool.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class TargetPool < GcpResourceBase name 'google_compute_target_pool' desc 'TargetPool' @@ -31,17 +31,10 @@ class TargetPool < GcpResourceBase attr_reader :name attr_reader :session_affinity attr_reader :region - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/regions/{{region}}/targetPools/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -72,4 +65,14 @@ def exists? def has_target_instance?(name, zone) instances.any? { |instance_self_link| instance_self_link.end_with?("zones/#{zone}/instances/#{name}") } end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/targetPools/{{name}}' + end end diff --git a/libraries/google_compute_target_pools.rb b/libraries/google_compute_target_pools.rb index 932724da4..f0bef0ba0 100644 --- a/libraries/google_compute_target_pools.rb +++ b/libraries/google_compute_target_pools.rb @@ -36,14 +36,6 @@ class TargetPools < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/regions/{{region}}/targetPools' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -52,7 +44,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -97,4 +89,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/targetPools' + end end diff --git a/libraries/google_compute_target_tcp_proxies.rb b/libraries/google_compute_target_tcp_proxies.rb index d3678bb91..a07c8108b 100644 --- a/libraries/google_compute_target_tcp_proxies.rb +++ b/libraries/google_compute_target_tcp_proxies.rb @@ -32,14 +32,6 @@ class TargetTcpProxys < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetTcpProxies' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -48,7 +40,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -89,4 +81,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetTcpProxies' + end end diff --git a/libraries/google_compute_target_tcp_proxy.rb b/libraries/google_compute_target_tcp_proxy.rb index 5927fe7a9..f7f088e67 100644 --- a/libraries/google_compute_target_tcp_proxy.rb +++ b/libraries/google_compute_target_tcp_proxy.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class TargetTcpProxy < GcpResourceBase name 'google_compute_target_tcp_proxy' desc 'TargetTcpProxy' @@ -27,17 +27,10 @@ class TargetTcpProxy < GcpResourceBase attr_reader :name attr_reader :proxy_header attr_reader :service - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/targetTcpProxies/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -58,4 +51,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/targetTcpProxies/{{name}}' + end end diff --git a/libraries/google_compute_url_map.rb b/libraries/google_compute_url_map.rb index 080e4adb5..b42df354a 100644 --- a/libraries/google_compute_url_map.rb +++ b/libraries/google_compute_url_map.rb @@ -18,7 +18,7 @@ require 'google/compute/property/urlmap_path_matchers' require 'google/compute/property/urlmap_tests' -# A provider to manage Google Compute Engine resources. +# A provider to manage Compute Engine resources. class UrlMap < GcpResourceBase name 'google_compute_url_map' desc 'UrlMap' @@ -33,17 +33,10 @@ class UrlMap < GcpResourceBase attr_reader :name attr_reader :path_matchers attr_reader :tests - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/urlMaps/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -67,4 +60,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/urlMaps/{{name}}' + end end diff --git a/libraries/google_compute_url_maps.rb b/libraries/google_compute_url_maps.rb index 7c3ef5f6e..2b003e32c 100644 --- a/libraries/google_compute_url_maps.rb +++ b/libraries/google_compute_url_maps.rb @@ -35,14 +35,6 @@ class UrlMaps < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/compute/v1/' - end - - def url - 'projects/{{project}}/global/urlMaps' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -51,7 +43,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -95,4 +87,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/global/urlMaps' + end end diff --git a/libraries/google_container_regional_cluster.rb b/libraries/google_container_regional_cluster.rb index 41576be66..04942518a 100644 --- a/libraries/google_container_regional_cluster.rb +++ b/libraries/google_container_regional_cluster.rb @@ -47,17 +47,10 @@ class RegionalCluster < GcpResourceBase attr_reader :current_node_count attr_reader :expire_time attr_reader :location - def base - 'https://container.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/locations/{{location}}/clusters/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end @@ -93,4 +86,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://container.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/locations/{{location}}/clusters/{{name}}' + end end diff --git a/libraries/google_container_regional_clusters.rb b/libraries/google_container_regional_clusters.rb index 14cf22aee..f4dc5cf66 100644 --- a/libraries/google_container_regional_clusters.rb +++ b/libraries/google_container_regional_clusters.rb @@ -47,14 +47,6 @@ class RegionalClusters < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://container.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/locations/{{location}}/clusters' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -63,7 +55,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -119,4 +111,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://container.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/locations/{{location}}/clusters' + end end diff --git a/libraries/google_dns_resource_record_set.rb b/libraries/google_dns_resource_record_set.rb index a7266353d..ff2677f2b 100644 --- a/libraries/google_dns_resource_record_set.rb +++ b/libraries/google_dns_resource_record_set.rb @@ -15,7 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Cloud DNS resources. +# A provider to manage Cloud DNS resources. class ResourceRecordSet < GcpResourceBase name 'google_dns_resource_record_set' desc 'ResourceRecordSet' @@ -26,17 +26,10 @@ class ResourceRecordSet < GcpResourceBase attr_reader :ttl attr_reader :target attr_reader :managed_zone - def base - 'https://www.googleapis.com/dns/v1/' - end - - def url - 'projects/{{project}}/managedZones/{{managed_zone}}/rrsets?name={{name}}&type={{type}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - fetched = @connection.fetch(base, url, params) + fetched = @connection.fetch(product_url, resource_base_url, params) @fetched = unwrap(fetched, params) parse unless @fetched.nil? end @@ -69,4 +62,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://www.googleapis.com/dns/v1/' + end + + def resource_base_url + 'projects/{{project}}/managedZones/{{managed_zone}}/rrsets?name={{name}}&type={{type}}' + end end diff --git a/libraries/google_dns_resource_record_sets.rb b/libraries/google_dns_resource_record_sets.rb index 6c54d9495..ce288e71b 100644 --- a/libraries/google_dns_resource_record_sets.rb +++ b/libraries/google_dns_resource_record_sets.rb @@ -31,14 +31,6 @@ class ResourceRecordSets < GcpResourceBase filter_table_config.connect(self, :table) - def base - 'https://www.googleapis.com/dns/v1/' - end - - def url - 'projects/{{project}}/managedZones/{{managed_zone}}/rrsets' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -47,7 +39,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -87,4 +79,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://www.googleapis.com/dns/v1/' + end + + def resource_base_url + 'projects/{{project}}/managedZones/{{managed_zone}}/rrsets' + end end diff --git a/libraries/google_pubsub_subscription.rb b/libraries/google_pubsub_subscription.rb index 6a02a71f8..75027a612 100644 --- a/libraries/google_pubsub_subscription.rb +++ b/libraries/google_pubsub_subscription.rb @@ -16,7 +16,7 @@ require 'gcp_backend' require 'google/pubsub/property/subscription_push_config' -# A provider to manage Google Cloud Pub/Sub resources. +# A provider to manage Cloud Pub/Sub resources. class Subscription < GcpResourceBase name 'google_pubsub_subscription' desc 'Subscription' @@ -24,25 +24,20 @@ class Subscription < GcpResourceBase attr_reader :name attr_reader :topic + attr_reader :labels attr_reader :push_config attr_reader :ack_deadline_seconds - def base - 'https://pubsub.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/subscriptions/{{name}}' - end def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end def parse @name = name_from_self_link(@fetched['name']) @topic = @fetched['topic'] + @labels = @fetched['labels'] @push_config = GoogleInSpec::Pubsub::Property::SubscriptionPushConfig.new(@fetched['pushConfig']) @ack_deadline_seconds = @fetched['ackDeadlineSeconds'] end @@ -55,4 +50,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://pubsub.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/subscriptions/{{name}}' + end end diff --git a/libraries/google_pubsub_subscriptions.rb b/libraries/google_pubsub_subscriptions.rb index be1bff1a9..a2629dd30 100644 --- a/libraries/google_pubsub_subscriptions.rb +++ b/libraries/google_pubsub_subscriptions.rb @@ -25,19 +25,12 @@ class Subscriptions < GcpResourceBase filter_table_config.add(:names, field: :name) filter_table_config.add(:topics, field: :topic) + filter_table_config.add(:labels, field: :labels) filter_table_config.add(:push_configs, field: :push_config) filter_table_config.add(:ack_deadline_seconds, field: :ack_deadline_seconds) filter_table_config.connect(self, :table) - def base - 'https://pubsub.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/subscriptions' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -46,7 +39,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -76,6 +69,7 @@ def transformers { 'name' => ->(obj) { return :name, name_from_self_link(obj['name']) }, 'topic' => ->(obj) { return :topic, obj['topic'] }, + 'labels' => ->(obj) { return :labels, obj['labels'] }, 'pushConfig' => ->(obj) { return :push_config, GoogleInSpec::Pubsub::Property::SubscriptionPushConfig.new(obj['pushConfig']) }, 'ackDeadlineSeconds' => ->(obj) { return :ack_deadline_seconds, obj['ackDeadlineSeconds'] }, } @@ -85,4 +79,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://pubsub.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/subscriptions' + end end diff --git a/libraries/google_pubsub_topic.rb b/libraries/google_pubsub_topic.rb index 163cddfcf..85d438bab 100644 --- a/libraries/google_pubsub_topic.rb +++ b/libraries/google_pubsub_topic.rb @@ -15,29 +15,24 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' -# A provider to manage Google Cloud Pub/Sub resources. +# A provider to manage Cloud Pub/Sub resources. class Topic < GcpResourceBase name 'google_pubsub_topic' desc 'Topic' supports platform: 'gcp' attr_reader :name - def base - 'https://pubsub.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/topics/{{name}}' - end + attr_reader :labels def initialize(params) super(params.merge({ use_http_transport: true })) - @fetched = @connection.fetch(base, url, params) + @fetched = @connection.fetch(product_url, resource_base_url, params) parse unless @fetched.nil? end def parse @name = name_from_self_link(@fetched['name']) + @labels = @fetched['labels'] end # Handles parsing RFC3339 time string @@ -48,4 +43,14 @@ def parse_time_string(time_string) def exists? !@fetched.nil? end + + private + + def product_url + 'https://pubsub.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/topics/{{name}}' + end end diff --git a/libraries/google_pubsub_topics.rb b/libraries/google_pubsub_topics.rb index 8399223b5..9a79c67af 100644 --- a/libraries/google_pubsub_topics.rb +++ b/libraries/google_pubsub_topics.rb @@ -24,17 +24,10 @@ class Topics < GcpResourceBase filter_table_config = FilterTable.create filter_table_config.add(:names, field: :name) + filter_table_config.add(:labels, field: :labels) filter_table_config.connect(self, :table) - def base - 'https://pubsub.googleapis.com/v1/' - end - - def url - 'projects/{{project}}/topics' - end - def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params @@ -43,7 +36,7 @@ def initialize(params = {}) def fetch_wrapped_resource(wrap_path) # fetch_resource returns an array of responses (to handle pagination) - result = @connection.fetch_all(base, url, @params) + result = @connection.fetch_all(product_url, resource_base_url, @params) return if result.nil? # Conversion of string -> object hash to symbol -> object hash that InSpec needs @@ -72,6 +65,7 @@ def transform(key, value) def transformers { 'name' => ->(obj) { return :name, name_from_self_link(obj['name']) }, + 'labels' => ->(obj) { return :labels, obj['labels'] }, } end @@ -79,4 +73,14 @@ def transformers def parse_time_string(time_string) time_string ? Time.parse(time_string) : nil end + + private + + def product_url + 'https://pubsub.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/topics' + end end diff --git a/libraries/google_sourcerepo_repositories.rb b/libraries/google_sourcerepo_repositories.rb new file mode 100644 index 000000000..20cd31324 --- /dev/null +++ b/libraries/google_sourcerepo_repositories.rb @@ -0,0 +1,88 @@ +# 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 Repositorys < GcpResourceBase + name 'google_sourcerepo_repositories' + desc 'Repository plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:names, field: :name) + filter_table_config.add(:urls, field: :url) + filter_table_config.add(:sizes, field: :size) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('repos') + 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) + 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'] }, + 'url' => ->(obj) { return :url, obj['url'] }, + 'size' => ->(obj) { return :size, obj['size'] }, + } + 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://sourcerepo.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/repos' + end +end diff --git a/libraries/google_sourcerepo_repository.rb b/libraries/google_sourcerepo_repository.rb new file mode 100644 index 000000000..aec2da712 --- /dev/null +++ b/libraries/google_sourcerepo_repository.rb @@ -0,0 +1,58 @@ +# 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 Source Repositories resources. +class Repository < GcpResourceBase + name 'google_sourcerepo_repository' + desc 'Repository' + supports platform: 'gcp' + + attr_reader :name + attr_reader :url + attr_reader :size + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @fetched = @connection.fetch(product_url, resource_base_url, params) + parse unless @fetched.nil? + end + + def parse + @name = @fetched['name'] + @url = @fetched['url'] + @size = @fetched['size'] + 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 + + private + + def product_url + 'https://sourcerepo.googleapis.com/v1/' + end + + def resource_base_url + 'projects/{{project}}/repos/{{name}}' + end +end diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index cedbc52b0..b940273d5 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -106,6 +106,10 @@ variable "bigquery_table" { type = "map" } +variable "repository" { + type = "map" +} + resource "google_compute_ssl_policy" "custom-ssl-policy" { name = "${var.ssl_policy["name"]}" min_tls_version = "${var.ssl_policy["min_tls_version"]}" @@ -433,4 +437,9 @@ resource "google_bigquery_table" "gcp-inspec-bigquery-table" { description = "${var.bigquery_table["description"]}" expiration_time = "${var.bigquery_table["expiration_time"]}" +} + +resource "google_sourcerepo_repository" "gcp-inspec-sourcerepo-repository" { + project = "${var.gcp_project_id}" + name = "${var.repository["name"]}" } \ No newline at end of file diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index b7ca91f40..3c3dde1ce 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -183,4 +183,7 @@ bigquery_table: table_id: inspec_gcp_bigquery_table description: A BigQuery table expiration_time: 1738882264000 - time_partitioning_type: DAY \ No newline at end of file + time_partitioning_type: DAY + +repository: + name: inspec-gcp-repository \ No newline at end of file diff --git a/test/integration/verify/controls/google_bigquery_table.rb b/test/integration/verify/controls/google_bigquery_table.rb new file mode 100644 index 000000000..b5fdb7f3d --- /dev/null +++ b/test/integration/verify/controls/google_bigquery_table.rb @@ -0,0 +1,48 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_bigquery_table resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +bigquery_table = attribute('bigquery_table', default: { + "table_id": "inspec_gcp_bigquery_table", + "description": "A BigQuery table", + "expiration_time": 1738882264000, + "time_partitioning_type": "DAY" +}, description: 'BigQuery table definition') +dataset = attribute('dataset', default: { + "dataset_id": "inspec_gcp_dataset", + "friendly_name": "A BigQuery dataset test", + "description": "Test BigQuery dataset description", + "location": "EU", + "default_table_expiration_ms": 3600000, + "access_writer_role": "WRITER", + "access_writer_special_group": "projectWriters" +}, description: 'BigQuery dataset definition') +control 'google_bigquery_table-1.0' do + impact 1.0 + title 'google_bigquery_table resource test' + + describe google_bigquery_table(project: gcp_project_id, dataset: dataset['dataset_id'], name: bigquery_table['table_id']) do + it { should exist } + + its('expiration_time') { should cmp bigquery_table['expiration_time'] } + its('time_partitioning.type') { should eq bigquery_table['time_partitioning_type'] } + its('description') { should eq bigquery_table['description'] } + end + + describe google_bigquery_table(project: gcp_project_id, dataset: dataset['dataset_id'], name: 'nonexistent') do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_bigquery_tables.rb b/test/integration/verify/controls/google_bigquery_tables.rb new file mode 100644 index 000000000..f9624d493 --- /dev/null +++ b/test/integration/verify/controls/google_bigquery_tables.rb @@ -0,0 +1,45 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_bigquery_tables resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +bigquery_table = attribute('bigquery_table', default: { + "table_id": "inspec_gcp_bigquery_table", + "description": "A BigQuery table", + "expiration_time": 1738882264000, + "time_partitioning_type": "DAY" +}, description: 'BigQuery table definition') +dataset = attribute('dataset', default: { + "dataset_id": "inspec_gcp_dataset", + "friendly_name": "A BigQuery dataset test", + "description": "Test BigQuery dataset description", + "location": "EU", + "default_table_expiration_ms": 3600000, + "access_writer_role": "WRITER", + "access_writer_special_group": "projectWriters" +}, description: 'BigQuery dataset definition') +control 'google_bigquery_tables-1.0' do + impact 1.0 + title 'google_bigquery_tables resource test' + + describe.one do + google_bigquery_tables(project: gcp_project_id, dataset: dataset['dataset_id']).table_references.each do |table_reference| + describe google_bigquery_table(project: gcp_project_id, dataset: dataset['dataset_id'], name: table_reference.table_id) do + its('expiration_time') { should cmp bigquery_table['expiration_time'] } + its('description') { should eq bigquery_table['description'] } + end + end + end +end diff --git a/test/integration/verify/controls/google_sourcerepo_repositories.rb b/test/integration/verify/controls/google_sourcerepo_repositories.rb new file mode 100644 index 000000000..de5e72980 --- /dev/null +++ b/test/integration/verify/controls/google_sourcerepo_repositories.rb @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_sourcerepo_repositories resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +repository = attribute('repository', default: { + "name": "inspec-gcp-repository" +}, description: 'Source Repository definition') +control 'google_sourcerepo_repositories-1.0' do + impact 1.0 + title 'google_sourcerepo_repositories resource test' + + repo_name = repository['name'] + describe.one do + google_sourcerepo_repositories(project: gcp_project_id).names.each do |name| + describe name do + it { should match /\/repos\/#{repo_name}$/ } + end + end + end +end diff --git a/test/integration/verify/controls/google_sourcerepo_repository.rb b/test/integration/verify/controls/google_sourcerepo_repository.rb new file mode 100644 index 000000000..dd325e0c8 --- /dev/null +++ b/test/integration/verify/controls/google_sourcerepo_repository.rb @@ -0,0 +1,32 @@ +# ---------------------------------------------------------------------------- +# +# *** 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_sourcerepo_repository resource.' + +gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.') +repository = attribute('repository', default: { + "name": "inspec-gcp-repository" +}, description: 'Source Repository definition') +control 'google_sourcerepo_repository-1.0' do + impact 1.0 + title 'google_sourcerepo_repository resource test' + + describe google_sourcerepo_repository(project: gcp_project_id, name: repository['name']) do + it { should exist } + end + + describe google_sourcerepo_repository(project: gcp_project_id, name: 'nonexistent') do + it { should_not exist } + end +end