diff --git a/docs/resources/google_bigtableadmin_project_instance_cluster_backup.md b/docs/resources/google_bigtableadmin_project_instance_cluster_backup.md new file mode 100644 index 00000000..fe1ffe7d --- /dev/null +++ b/docs/resources/google_bigtableadmin_project_instance_cluster_backup.md @@ -0,0 +1,92 @@ ++++ + +title = "google_bigtableadmin_project_instance_cluster_backup Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_bigtableadmin_project_instance_cluster_backup" +identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_cluster_backup Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_bigtableadmin_project_instance_cluster_backup` InSpec audit resource to test the properties of a test a Google ProjectInstanceClusterBackup. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_bigtableadmin_project_instance_cluster_backup` is used to test a Google ProjectInstanceClusterBackup resource + +## Examples +``` +describe google_bigtableadmin_project_instance_cluster_backup(name: ' value_name') do + it { should exist } + its('name') { should cmp 'value_name' } + its('source_table') { should cmp 'value_sourcetable' } + its('source_backup') { should cmp 'value_sourcebackup' } + its('expire_time') { should cmp 'value_expiretime' } + its('start_time') { should cmp 'value_starttime' } + its('end_time') { should cmp 'value_endtime' } + its('size_bytes') { should cmp 'value_sizebytes' } + its('state') { should cmp 'value_state' } + +end + +describe google_bigtableadmin_project_instance_cluster_backup(name: "does_not_exit") do + it { should_not exist } +end +``` + +## Parameters +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster_backup` resource: + +## Properties +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster_backup` resource: + + + * `name`: A globally unique identifier for the backup which cannot be changed. Values are of the form `projects/{project}/instances/{instance}/clusters/{cluster}/ backups/_a-zA-Z0-9*` The final segment of the name must be between 1 and 50 characters in length. The backup is stored in the cluster identified by the prefix of the backup name of the form `projects/{project}/instances/{instance}/clusters/{cluster}`. + + * `source_table`: Required. Immutable. Name of the table from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects/{project}/instances/{instance}/tables/{source_table}`. + + * `source_backup`: Output only. Name of the backup from which this backup was copied. If a backup is not created by copying a backup, this field will be empty. Values are of the form: projects//instances//clusters//backups/ + + * `expire_time`: Required. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 90 days from the time the request is received. Once the `expire_time` has passed, Cloud Bigtable will delete the backup and free the resources used by the backup. + + * `start_time`: Output only. `start_time` is the time that the backup was started (i.e. approximately the time the CreateBackup request is received). The row data in this backup will be no older than this timestamp. + + * `end_time`: Output only. `end_time` is the time that the backup was finished. The row data in the backup will be no newer than this timestamp. + + * `size_bytes`: Output only. Size of the backup in bytes. + + * `state`: Output only. The current state of the backup. + Possible values: + * STATE_UNSPECIFIED + * CREATING + * READY + + * `encryption_info`: Encryption information for a given resource. If this resource is protected with customer managed encryption, the in-use Cloud Key Management Service (Cloud KMS) key version is specified along with its status. + + * `encryption_type`: Output only. The type of encryption used to protect this resource. + Possible values: + * ENCRYPTION_TYPE_UNSPECIFIED + * GOOGLE_DEFAULT_ENCRYPTION + * CUSTOMER_MANAGED_ENCRYPTION + + * `encryption_status`: The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). + + * `code`: The status code, which should be an enum value of google.rpc.Code. + + * `message`: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. + + * `details`: A list of messages that carry the error details. There is a common set of message types for APIs to use. + + * `kms_key_version`: Output only. The version of the Cloud KMS key specified in the parent cluster that is in use for the data underlying this table. + + +## GCP Permissions + +Ensure the [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_bigtableadmin_project_instance_cluster_backups.md b/docs/resources/google_bigtableadmin_project_instance_cluster_backups.md new file mode 100644 index 00000000..4ddd42cb --- /dev/null +++ b/docs/resources/google_bigtableadmin_project_instance_cluster_backups.md @@ -0,0 +1,64 @@ ++++ + +title = "google_bigtableadmin_project_instance_cluster_backups Resource" +platform = "gcp" +draft = false +gh_repo = "inspec-gcp" + + +[menu.inspec] + +title = "google_bigtableadmin_project_instance_cluster_backups" +identifier = "inspec/resources/gcp/google_bigtableadmin_project_instance_cluster_backups Resource" +parent = "inspec/resources/gcp" ++++ + +Use the `google_bigtableadmin_project_instance_cluster_backups` InSpec audit resource to test the properties of a test a Google ProjectInstanceClusterBackup. + +## Installation +{{% inspec_gcp_install %}} + +## Syntax +A `google_bigtableadmin_project_instance_cluster_backups` is used to test a Google ProjectInstanceClusterBackup resource + +## Examples +``` + describe google_bigtableadmin_project_instance_cluster_backups(parent: ' value_parent') do + it { should exist } + end +``` + +## Parameters +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster_backups` resource: + +See [google_bigtableadmin_project_instance_cluster_backup.md](google_bigtableadmin_project_instance_cluster_backup.md) for more detailed information +* `names`: an array of `google_bigtableadmin_project_instance_cluster_backup` name +* `source_tables`: an array of `google_bigtableadmin_project_instance_cluster_backup` source_table +* `source_backups`: an array of `google_bigtableadmin_project_instance_cluster_backup` source_backup +* `expire_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` expire_time +* `start_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` start_time +* `end_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` end_time +* `size_bytes`: an array of `google_bigtableadmin_project_instance_cluster_backup` size_bytes +* `states`: an array of `google_bigtableadmin_project_instance_cluster_backup` state +* `encryption_infos`: an array of `google_bigtableadmin_project_instance_cluster_backup` encryption_info +## Properties +Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster_backups` resource: + +See [google_bigtableadmin_project_instance_cluster_backup.md](google_bigtableadmin_project_instance_cluster_backup.md) for more detailed information +* `names`: an array of `google_bigtableadmin_project_instance_cluster_backup` name +* `source_tables`: an array of `google_bigtableadmin_project_instance_cluster_backup` source_table +* `source_backups`: an array of `google_bigtableadmin_project_instance_cluster_backup` source_backup +* `expire_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` expire_time +* `start_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` start_time +* `end_times`: an array of `google_bigtableadmin_project_instance_cluster_backup` end_time +* `size_bytes`: an array of `google_bigtableadmin_project_instance_cluster_backup` size_bytes +* `states`: an array of `google_bigtableadmin_project_instance_cluster_backup` state +* `encryption_infos`: an array of `google_bigtableadmin_project_instance_cluster_backup` encryption_info + +## Filter Criteria +This resource supports all of the above properties as filter criteria, which can be used +with `where` as a block or a method. + +## GCP Permissions + +Ensure the [https://bigtableadmin.googleapis.com/](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info.rb b/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info.rb new file mode 100644 index 00000000..bca9f216 --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status' +module GoogleInSpec + module Bigtableadmin + module Property + class ProjectInstanceClusterBackupEncryptionInfo + attr_reader :encryption_type + + attr_reader :encryption_status + + attr_reader :kms_key_version + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @encryption_type = args['encryptionType'] + @encryption_status = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterBackupEncryptionInfoEncryptionStatus.new(args['encryptionStatus'], to_s) + @kms_key_version = args['kmsKeyVersion'] + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterBackupEncryptionInfo" + end + end + end + end +end diff --git a/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status.rb b/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status.rb new file mode 100644 index 00000000..100935e4 --- /dev/null +++ b/libraries/google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Bigtableadmin + module Property + class ProjectInstanceClusterBackupEncryptionInfoEncryptionStatus + attr_reader :code + + attr_reader :message + + attr_reader :details + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @code = args['code'] + @message = args['message'] + @details = args['details'] + end + + def to_s + "#{@parent_identifier} ProjectInstanceClusterBackupEncryptionInfoEncryptionStatus" + end + end + end + end +end diff --git a/libraries/google_bigtableadmin_project_instance_cluster_backup.rb b/libraries/google_bigtableadmin_project_instance_cluster_backup.rb new file mode 100644 index 00000000..945788c5 --- /dev/null +++ b/libraries/google_bigtableadmin_project_instance_cluster_backup.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +require 'gcp_backend' +require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info' +require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status' + +# A provider to manage bigtableadmin resources. +class BigtableadminProjectInstanceClusterBackup < GcpResourceBase + name 'google_bigtableadmin_project_instance_cluster_backup' + desc 'ProjectInstanceClusterBackup' + supports platform: 'gcp' + + attr_reader :params + attr_reader :name + attr_reader :source_table + attr_reader :source_backup + attr_reader :expire_time + attr_reader :start_time + attr_reader :end_time + attr_reader :size_bytes + attr_reader :state + attr_reader :encryption_info + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get') + parse unless @fetched.nil? + end + + def parse + @name = @fetched['name'] + @source_table = @fetched['sourceTable'] + @source_backup = @fetched['sourceBackup'] + @expire_time = @fetched['expireTime'] + @start_time = @fetched['startTime'] + @end_time = @fetched['endTime'] + @size_bytes = @fetched['sizeBytes'] + @state = @fetched['state'] + @encryption_info = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterBackupEncryptionInfo.new(@fetched['encryptionInfo'], to_s) + end + + def exists? + !@fetched.nil? + end + + def to_s + "ProjectInstanceClusterBackup #{@params[:]}" + end + + private + + def product_url(_ = nil) + 'https://bigtableadmin.googleapis.com//v2/' + end + + def resource_base_url + '{{+name}}' + end +end diff --git a/libraries/google_bigtableadmin_project_instance_cluster_backups.rb b/libraries/google_bigtableadmin_project_instance_cluster_backups.rb new file mode 100644 index 00000000..221f0730 --- /dev/null +++ b/libraries/google_bigtableadmin_project_instance_cluster_backups.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +require 'gcp_backend' +class BigtableadminProjectInstanceClusterBackups < GcpResourceBase + name 'google_bigtableadmin_project_instance_cluster_backups' + desc 'ProjectInstanceClusterBackup plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:names, field: :name) + filter_table_config.add(:source_tables, field: :source_table) + filter_table_config.add(:source_backups, field: :source_backup) + filter_table_config.add(:expire_times, field: :expire_time) + filter_table_config.add(:start_times, field: :start_time) + filter_table_config.add(:end_times, field: :end_time) + filter_table_config.add(:size_bytes, field: :size_bytes) + filter_table_config.add(:states, field: :state) + filter_table_config.add(:encryption_infos, field: :encryption_info) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('projectInstanceClusterBackups') + end + + def fetch_wrapped_resource(wrap_path) + # fetch_resource returns an array of responses (to handle pagination) + result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get') + return if result.nil? + + # Conversion of string -> object hash to symbol -> object hash that InSpec needs + converted = [] + result.each do |response| + next if response.nil? || !response.key?(wrap_path) + response[wrap_path].each do |hash| + hash_with_symbols = {} + hash.each_key do |key| + name, value = transform(key, hash) + hash_with_symbols[name] = value + end + converted.push(hash_with_symbols) + end + end + + converted + end + + def transform(key, value) + return transformers[key].call(value) if transformers.key?(key) + + [key.to_sym, value] + end + + def transformers + { + 'name' => ->(obj) { [:name, obj['name']] }, + 'sourceTable' => ->(obj) { [:source_table, obj['sourceTable']] }, + 'sourceBackup' => ->(obj) { [:source_backup, obj['sourceBackup']] }, + 'expireTime' => ->(obj) { [:expire_time, obj['expireTime']] }, + 'startTime' => ->(obj) { [:start_time, obj['startTime']] }, + 'endTime' => ->(obj) { [:end_time, obj['endTime']] }, + 'sizeBytes' => ->(obj) { [:size_bytes, obj['sizeBytes']] }, + 'state' => ->(obj) { [:state, obj['state']] }, + 'encryptionInfo' => ->(obj) { [:encryption_info, GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterBackupEncryptionInfo.new(obj['encryptionInfo'], to_s)] }, + } + end + + private + + def product_url(_ = nil) + 'https://bigtableadmin.googleapis.com//v2/' + end + + def resource_base_url + '{{+parent}}/backups' + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backup.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backup.rb new file mode 100644 index 00000000..bbd077ed --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backup.rb @@ -0,0 +1,50 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_project_instance_cluster_backup resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_instance_cluster_backup = input('project_instance_cluster_backup', value: { + "name": "value_name", + "parent": "value_parent", + "source_table": "value_sourcetable", + "source_backup": "value_sourcebackup", + "expire_time": "value_expiretime", + "start_time": "value_starttime", + "end_time": "value_endtime", + "size_bytes": "value_sizebytes", + "state": "value_state" +}, description: 'project_instance_cluster_backup description') +control 'google_bigtableadmin_project_instance_cluster_backup-1.0' do + impact 1.0 + title 'google_bigtableadmin_project_instance_cluster_backup resource test' + + describe google_bigtableadmin_project_instance_cluster_backup(name: project_instance_cluster_backup['name']) do + it { should exist } + its('name') { should cmp project_instance_cluster_backup['name'] } + its('source_table') { should cmp project_instance_cluster_backup['source_table'] } + its('source_backup') { should cmp project_instance_cluster_backup['source_backup'] } + its('expire_time') { should cmp project_instance_cluster_backup['expire_time'] } + its('start_time') { should cmp project_instance_cluster_backup['start_time'] } + its('end_time') { should cmp project_instance_cluster_backup['end_time'] } + its('size_bytes') { should cmp project_instance_cluster_backup['size_bytes'] } + its('state') { should cmp project_instance_cluster_backup['state'] } + + end + + describe google_bigtableadmin_project_instance_cluster_backup(name: "does_not_exit") do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backups.rb b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backups.rb new file mode 100644 index 00000000..91cd4a02 --- /dev/null +++ b/test/integration/verify/controls/google_bigtableadmin_project_instance_cluster_backups.rb @@ -0,0 +1,37 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_bigtableadmin_project_instance_cluster_backups resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + project_instance_cluster_backup = input('project_instance_cluster_backup', value: { + "name": "value_name", + "parent": "value_parent", + "source_table": "value_sourcetable", + "source_backup": "value_sourcebackup", + "expire_time": "value_expiretime", + "start_time": "value_starttime", + "end_time": "value_endtime", + "size_bytes": "value_sizebytes", + "state": "value_state" +}, description: 'project_instance_cluster_backup description') +control 'google_bigtableadmin_project_instance_cluster_backups-1.0' do + impact 1.0 + title 'google_bigtableadmin_project_instance_cluster_backups resource test' + + describe google_bigtableadmin_project_instance_cluster_backups(parent: project_instance_cluster_backup['parent']) do + it { should exist } + end +end