-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from inspec/CHEF-12476-MAGIC-MODULE-bigtablea…
…dmin_v2-Projects__instances__clusters__backup CHEF-12476-MAGIC-MODULE-bigtableadmin_v2-Projects__instances__clusters__backup - Resource Implementation
- Loading branch information
Showing
8 changed files
with
503 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
+++ | ||
|
||
title = "google_bigtableadmin_cluster_backup Resource" | ||
platform = "gcp" | ||
draft = false | ||
gh_repo = "inspec-gcp" | ||
|
||
|
||
[menu.inspec] | ||
|
||
title = "google_bigtableadmin_cluster_backup" | ||
identifier = "inspec/resources/gcp/google_bigtableadmin_cluster_backup Resource" | ||
parent = "inspec/resources/gcp" | ||
+++ | ||
|
||
Use the `google_bigtableadmin_cluster_backup` InSpec audit resource to test the properties of a test a Google ClusterBackup. | ||
|
||
## Installation | ||
{{% inspec_gcp_install %}} | ||
|
||
## Syntax | ||
A `google_bigtableadmin_cluster_backup` is used to test a Google ClusterBackup resource | ||
|
||
## Examples | ||
``` | ||
describe google_bigtableadmin_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_cluster_backup(name: "does_not_exit") do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Parameters | ||
Properties that can be accessed from the `google_bigtableadmin_cluster_backup` resource: | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_bigtableadmin_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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
+++ | ||
|
||
title = "google_bigtableadmin_cluster_backups Resource" | ||
platform = "gcp" | ||
draft = false | ||
gh_repo = "inspec-gcp" | ||
|
||
|
||
[menu.inspec] | ||
|
||
title = "google_bigtableadmin_cluster_backups" | ||
identifier = "inspec/resources/gcp/google_bigtableadmin_cluster_backups Resource" | ||
parent = "inspec/resources/gcp" | ||
+++ | ||
|
||
Use the `google_bigtableadmin_cluster_backups` InSpec audit resource to test the properties of a test a Google ClusterBackup. | ||
|
||
## Installation | ||
{{% inspec_gcp_install %}} | ||
|
||
## Syntax | ||
A `google_bigtableadmin_cluster_backups` is used to test a Google ClusterBackup resource | ||
|
||
## Examples | ||
``` | ||
describe google_bigtableadmin_cluster_backups(parent: 'value_parent') do | ||
it { should exist } | ||
its('name') { should include 'value_name' } | ||
its('source_table') { should include 'value_sourcetable' } | ||
its('source_backup') { should include 'value_sourcebackup' } | ||
its('expire_time') { should include 'value_expiretime' } | ||
its('start_time') { should include 'value_starttime' } | ||
its('end_time') { should include 'value_endtime' } | ||
its('size_bytes') { should include 'value_sizebytes' } | ||
its('state') { should include 'value_state' } | ||
end | ||
``` | ||
|
||
## Parameters | ||
Properties that can be accessed from the `google_bigtableadmin_cluster_backups` resource: | ||
|
||
See [google_bigtableadmin_cluster_backup.md](google_bigtableadmin_cluster_backup.md) for more detailed information | ||
* `names`: an array of `google_bigtableadmin_cluster_backup` name | ||
* `source_tables`: an array of `google_bigtableadmin_cluster_backup` source_table | ||
* `source_backups`: an array of `google_bigtableadmin_cluster_backup` source_backup | ||
* `expire_times`: an array of `google_bigtableadmin_cluster_backup` expire_time | ||
* `start_times`: an array of `google_bigtableadmin_cluster_backup` start_time | ||
* `end_times`: an array of `google_bigtableadmin_cluster_backup` end_time | ||
* `size_bytes`: an array of `google_bigtableadmin_cluster_backup` size_bytes | ||
* `states`: an array of `google_bigtableadmin_cluster_backup` state | ||
* `encryption_infos`: an array of `google_bigtableadmin_cluster_backup` encryption_info | ||
## Properties | ||
Properties that can be accessed from the `google_bigtableadmin_cluster_backups` resource: | ||
|
||
See [google_bigtableadmin_cluster_backup.md](google_bigtableadmin_cluster_backup.md) for more detailed information | ||
* `names`: an array of `google_bigtableadmin_cluster_backup` name | ||
* `source_tables`: an array of `google_bigtableadmin_cluster_backup` source_table | ||
* `source_backups`: an array of `google_bigtableadmin_cluster_backup` source_backup | ||
* `expire_times`: an array of `google_bigtableadmin_cluster_backup` expire_time | ||
* `start_times`: an array of `google_bigtableadmin_cluster_backup` start_time | ||
* `end_times`: an array of `google_bigtableadmin_cluster_backup` end_time | ||
* `size_bytes`: an array of `google_bigtableadmin_cluster_backup` size_bytes | ||
* `states`: an array of `google_bigtableadmin_cluster_backup` state | ||
* `encryption_infos`: an array of `google_bigtableadmin_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. |
41 changes: 41 additions & 0 deletions
41
libraries/google/bigtableadmin/property/clusterbackup_encryption_info.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/clusterbackup_encryption_info_encryption_status' | ||
module GoogleInSpec | ||
module Bigtableadmin | ||
module Property | ||
class ClusterBackupEncryptionInfo | ||
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::ClusterBackupEncryptionInfoEncryptionStatus.new(args['encryptionStatus'], to_s) | ||
@kms_key_version = args['kmsKeyVersion'] | ||
end | ||
|
||
def to_s | ||
"#{@parent_identifier} ClusterBackupEncryptionInfo" | ||
end | ||
end | ||
end | ||
end | ||
end |
40 changes: 40 additions & 0 deletions
40
libraries/google/bigtableadmin/property/clusterbackup_encryption_info_encryption_status.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ClusterBackupEncryptionInfoEncryptionStatus | ||
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} ClusterBackupEncryptionInfoEncryptionStatus" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/clusterbackup_encryption_info' | ||
require 'google/bigtableadmin/property/clusterbackup_encryption_info_encryption_status' | ||
|
||
# A provider to manage bigtableadmin resources. | ||
class BigtableadminClusterBackup < GcpResourceBase | ||
name 'google_bigtableadmin_cluster_backup' | ||
desc 'ClusterBackup' | ||
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::ClusterBackupEncryptionInfo.new(@fetched['encryptionInfo'], to_s) | ||
end | ||
|
||
def exists? | ||
!@fetched.nil? | ||
end | ||
|
||
def to_s | ||
"ClusterBackup #{@params[:name]}" | ||
end | ||
|
||
private | ||
|
||
def product_url(_ = nil) | ||
'https://bigtableadmin.googleapis.com/v2/' | ||
end | ||
|
||
def resource_base_url | ||
'{{name}}' | ||
end | ||
end |
Oops, something went wrong.