Skip to content

Commit

Permalink
updated resource name and testcases
Browse files Browse the repository at this point in the history
Signed-off-by: balasubramanian-s <balasubramanian.s@progress.com>
  • Loading branch information
balasubramanian-s committed Sep 24, 2024
1 parent 54029c3 commit 690ce08
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
+++

title = "google_bigtableadmin_project_instance_cluster_backup Resource"
title = "google_bigtableadmin_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"
title = "google_bigtableadmin_cluster_backup"
identifier = "inspec/resources/gcp/google_bigtableadmin_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.
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_project_instance_cluster_backup` is used to test a Google ProjectInstanceClusterBackup resource
A `google_bigtableadmin_cluster_backup` is used to test a Google ClusterBackup resource

## Examples
```
describe google_bigtableadmin_project_instance_cluster_backup(name: ' value_name') do
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' }
Expand All @@ -33,19 +33,18 @@ describe google_bigtableadmin_project_instance_cluster_backup(name: ' value_name
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
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_project_instance_cluster_backup` resource:
Properties that can be accessed from the `google_bigtableadmin_cluster_backup` resource:

## Properties
Properties that can be accessed from the `google_bigtableadmin_project_instance_cluster_backup` resource:
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}`.
Expand Down
72 changes: 72 additions & 0 deletions docs/resources/google_bigtableadmin_cluster_backups.md
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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status'
require 'google/bigtableadmin/property/clusterbackup_encryption_info_encryption_status'
module GoogleInSpec
module Bigtableadmin
module Property
class ProjectInstanceClusterBackupEncryptionInfo
class ClusterBackupEncryptionInfo
attr_reader :encryption_type

attr_reader :encryption_status
Expand All @@ -28,12 +28,12 @@ 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)
@encryption_status = GoogleInSpec::Bigtableadmin::Property::ClusterBackupEncryptionInfoEncryptionStatus.new(args['encryptionStatus'], to_s)
@kms_key_version = args['kmsKeyVersion']
end

def to_s
"#{@parent_identifier} ProjectInstanceClusterBackupEncryptionInfo"
"#{@parent_identifier} ClusterBackupEncryptionInfo"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
module GoogleInSpec
module Bigtableadmin
module Property
class ProjectInstanceClusterBackupEncryptionInfoEncryptionStatus
class ClusterBackupEncryptionInfoEncryptionStatus
attr_reader :code

attr_reader :message
Expand All @@ -32,7 +32,7 @@ def initialize(args = nil, parent_identifier = nil)
end

def to_s
"#{@parent_identifier} ProjectInstanceClusterBackupEncryptionInfoEncryptionStatus"
"#{@parent_identifier} ClusterBackupEncryptionInfoEncryptionStatus"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info'
require 'google/bigtableadmin/property/projectinstanceclusterbackup_encryption_info_encryption_status'
require 'google/bigtableadmin/property/clusterbackup_encryption_info'
require 'google/bigtableadmin/property/clusterbackup_encryption_info_encryption_status'

# A provider to manage bigtableadmin resources.
class BigtableadminProjectInstanceClusterBackup < GcpResourceBase
name 'google_bigtableadmin_project_instance_cluster_backup'
desc 'ProjectInstanceClusterBackup'
class BigtableadminClusterBackup < GcpResourceBase
name 'google_bigtableadmin_cluster_backup'
desc 'ClusterBackup'
supports platform: 'gcp'

attr_reader :params
Expand Down Expand Up @@ -50,24 +50,24 @@ def parse
@end_time = @fetched['endTime']
@size_bytes = @fetched['sizeBytes']
@state = @fetched['state']
@encryption_info = GoogleInSpec::Bigtableadmin::Property::ProjectInstanceClusterBackupEncryptionInfo.new(@fetched['encryptionInfo'], to_s)
@encryption_info = GoogleInSpec::Bigtableadmin::Property::ClusterBackupEncryptionInfo.new(@fetched['encryptionInfo'], to_s)
end

def exists?
!@fetched.nil?
end

def to_s
"ProjectInstanceClusterBackup #{@params[:]}"
"ClusterBackup #{@params[:name]}"
end

private

def product_url(_ = nil)
'https://bigtableadmin.googleapis.com//v2/'
'https://bigtableadmin.googleapis.com/v2/'
end

def resource_base_url
'{{+name}}'
'{{name}}'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
class BigtableadminProjectInstanceClusterBackups < GcpResourceBase
name 'google_bigtableadmin_project_instance_cluster_backups'
desc 'ProjectInstanceClusterBackup plural resource'
class BigtableadminClusterBackups < GcpResourceBase
name 'google_bigtableadmin_cluster_backups'
desc 'ClusterBackup plural resource'
supports platform: 'gcp'

attr_reader :table
Expand All @@ -38,7 +38,7 @@ class BigtableadminProjectInstanceClusterBackups < GcpResourceBase
def initialize(params = {})
super(params.merge({ use_http_transport: true }))
@params = params
@table = fetch_wrapped_resource('projectInstanceClusterBackups')
@table = fetch_wrapped_resource('backups')
end

def fetch_wrapped_resource(wrap_path)
Expand Down Expand Up @@ -79,17 +79,17 @@ def transformers
'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)] },
'encryptionInfo' => ->(obj) { [:encryption_info, GoogleInSpec::Bigtableadmin::Property::ClusterBackupEncryptionInfo.new(obj['encryptionInfo'], to_s)] },
}
end

private

def product_url(_ = nil)
'https://bigtableadmin.googleapis.com//v2/'
'https://bigtableadmin.googleapis.com/v2/'
end

def resource_base_url
'{{+parent}}/backups'
'{{parent}}/backups'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ----------------------------------------------------------------------------
#
# *** 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_cluster_backup resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')

cluster_backup = input('cluster_backup', value: {
"name": "projects/ppradhan/instances/inspec-test/clusters/inspec-test-c1/backups/inspec-day1-backup",
"parent": "projects/ppradhan/instances/inspec-test/clusters/inspec-test-c1",
"source_table": "projects/ppradhan/instances/inspec-test/tables/inspec",
"source_backup": "value_sourcebackup",
"expire_time": "2024-09-25T07:08:29.584Z",
"start_time": "2024-09-24T07:08:31.252667Z",
"end_time": "2024-09-24T07:08:31.627350Z",
"size_bytes": "value_sizebytes",
"state": "READY"
}, description: 'cluster_backup description')
control 'google_bigtableadmin_cluster_backup-1.0' do
impact 1.0
title 'google_bigtableadmin_cluster_backup resource test'

describe google_bigtableadmin_cluster_backup(name: cluster_backup['name']) do
it { should exist }
its('name') { should cmp cluster_backup['name'] }
its('source_table') { should cmp cluster_backup['source_table'] }
its('expire_time') { should cmp cluster_backup['expire_time'] }
its('start_time') { should cmp cluster_backup['start_time'] }
its('end_time') { should cmp cluster_backup['end_time'] }
its('state') { should cmp cluster_backup['state'] }

end

describe google_bigtableadmin_cluster_backup(name: "does_not_exit") do
it { should_not exist }
end
end
Loading

0 comments on commit 690ce08

Please sign in to comment.