Skip to content

Commit

Permalink
Merge pull request #231 from inspec/CHEF-12475-v2-MAGIC-MODULE-bigtab…
Browse files Browse the repository at this point in the history
…leadmin_v2-Projects__instances__cluster

CHEF-12475-v2-MAGIC-MODULE-bigtableadmin_v2-Projects__instances__cluster - Resource Implementation
  • Loading branch information
sa-progress authored Jul 23, 2024
2 parents 5325bf9 + 78f82ae commit 108b350
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 1 deletion.
242 changes: 242 additions & 0 deletions mmv1/products/bigtableadmin/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@

--- !ruby/object:Api::Product
name: bigtableadmin
display_name: bigtableadmin
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://bigtableadmin.googleapis.com//v2/
scopes:
- https://bigtableadmin.googleapis.com//auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: https://bigtableadmin.googleapis.com/
url: https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/
objects:

- !ruby/object:Api::Resource
name: ProjectInstanceCluster
base_url: '{{+parent}}/clusters'
self_link: '{{+name}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/bigtableadmin/docs'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{op_id}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
A resizable group of nodes in a particular cloud location, capable of serving all Tables in the parent Instance.
properties:

- !ruby/object:Api::Type::String
name: 'name'
description: |
The unique name of the cluster. Values are of the form `projects/{project}/instances/{instance}/clusters/a-z*`.
- !ruby/object:Api::Type::String
name: 'location'
description: |
Immutable. The location where this cluster's nodes and storage reside. For best performance, clients should be located as close as possible to this cluster. Currently only zones are supported, so values should be of the form `projects/{project}/locations/{zone}`.
- !ruby/object:Api::Type::Enum
name: 'state'
description: |
Output only. The current state of the cluster.
values:
- :STATE_NOT_KNOWN
- :READY
- :CREATING
- :RESIZING
- :DISABLED
- !ruby/object:Api::Type::Integer
name: 'serveNodes'
description: |
The number of nodes in the cluster. If no value is set, Cloud Bigtable automatically allocates nodes based on your data footprint and optimized for 50% storage utilization.
- !ruby/object:Api::Type::NestedObject
name: 'clusterConfig'
description: |
Configuration for a cluster.
properties:
- !ruby/object:Api::Type::NestedObject
name: 'clusterAutoscalingConfig'
description: |
Autoscaling config for a cluster.
properties:
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingLimits'
description: |
Limits for the number of nodes a Cluster can autoscale up/down to.
properties:
- !ruby/object:Api::Type::Integer
name: 'minServeNodes'
description: |
Required. Minimum number of nodes to scale down to.
- !ruby/object:Api::Type::Integer
name: 'maxServeNodes'
description: |
Required. Maximum number of nodes to scale up to.
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingTargets'
description: |
The Autoscaling targets for a Cluster. These determine the recommended nodes.
properties:
- !ruby/object:Api::Type::Integer
name: 'cpuUtilizationPercent'
description: |
The cpu utilization that the Autoscaler should be trying to achieve. This number is on a scale from 0 (no utilization) to 100 (total utilization), and is limited between 10 and 80, otherwise it will return INVALID_ARGUMENT error.
- !ruby/object:Api::Type::Integer
name: 'storageUtilizationGibPerNode'
description: |
The storage utilization that the Autoscaler should be trying to achieve. This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, it will be treated as if it were set to the default value: 2560 for SSD, 8192 for HDD.
- !ruby/object:Api::Type::Enum
name: 'defaultStorageType'
description: |
Immutable. The type of storage used by this cluster to serve its parent instance's tables, unless explicitly overridden.
values:
- :STORAGE_TYPE_UNSPECIFIED
- :SSD
- :HDD
- !ruby/object:Api::Type::NestedObject
name: 'encryptionConfig'
description: |
Cloud Key Management Service (Cloud KMS) settings for a CMEK-protected cluster.
properties:
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
description: |
Describes the Cloud KMS encryption key that will be used to protect the destination Bigtable cluster. The requirements for this key are: 1) The Cloud Bigtable service account associated with the project that contains this cluster must be granted the `cloudkms.cryptoKeyEncrypterDecrypter` role on the CMEK key. 2) Only regional keys can be used and the region of the CMEK key must match the region of the cluster. Values are of the form `projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}`

--- !ruby/object:Api::Product
name: bigtableadmin
display_name: bigtableadmin
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://bigtableadmin.googleapis.com//v2/
scopes:
- https://bigtableadmin.googleapis.com//auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: https://bigtableadmin.googleapis.com/
url: https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com/
objects:

- !ruby/object:Api::Resource
name: ProjectInstanceCluster
base_url: '{{+parent}}/clusters'
self_link: '{{+name}}'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
api: 'https://cloud.google.com/bigtableadmin/docs'
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{op_id}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
description: |-
A resizable group of nodes in a particular cloud location, capable of serving all Tables in the parent Instance.
properties:

- !ruby/object:Api::Type::String
name: 'name'
description: |
The unique name of the cluster. Values are of the form `projects/{project}/instances/{instance}/clusters/a-z*`.
- !ruby/object:Api::Type::String
name: 'location'
description: |
Immutable. The location where this cluster's nodes and storage reside. For best performance, clients should be located as close as possible to this cluster. Currently only zones are supported, so values should be of the form `projects/{project}/locations/{zone}`.
- !ruby/object:Api::Type::Enum
name: 'state'
description: |
Output only. The current state of the cluster.
values:
- :STATE_NOT_KNOWN
- :READY
- :CREATING
- :RESIZING
- :DISABLED
- !ruby/object:Api::Type::Integer
name: 'serveNodes'
description: |
The number of nodes in the cluster. If no value is set, Cloud Bigtable automatically allocates nodes based on your data footprint and optimized for 50% storage utilization.
- !ruby/object:Api::Type::NestedObject
name: 'clusterConfig'
description: |
Configuration for a cluster.
properties:
- !ruby/object:Api::Type::NestedObject
name: 'clusterAutoscalingConfig'
description: |
Autoscaling config for a cluster.
properties:
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingLimits'
description: |
Limits for the number of nodes a Cluster can autoscale up/down to.
properties:
- !ruby/object:Api::Type::Integer
name: 'minServeNodes'
description: |
Required. Minimum number of nodes to scale down to.
- !ruby/object:Api::Type::Integer
name: 'maxServeNodes'
description: |
Required. Maximum number of nodes to scale up to.
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingTargets'
description: |
The Autoscaling targets for a Cluster. These determine the recommended nodes.
properties:
- !ruby/object:Api::Type::Integer
name: 'cpuUtilizationPercent'
description: |
The cpu utilization that the Autoscaler should be trying to achieve. This number is on a scale from 0 (no utilization) to 100 (total utilization), and is limited between 10 and 80, otherwise it will return INVALID_ARGUMENT error.
- !ruby/object:Api::Type::Integer
name: 'storageUtilizationGibPerNode'
description: |
The storage utilization that the Autoscaler should be trying to achieve. This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, it will be treated as if it were set to the default value: 2560 for SSD, 8192 for HDD.
- !ruby/object:Api::Type::Enum
name: 'defaultStorageType'
description: |
Immutable. The type of storage used by this cluster to serve its parent instance's tables, unless explicitly overridden.
values:
- :STORAGE_TYPE_UNSPECIFIED
- :SSD
- :HDD
- !ruby/object:Api::Type::NestedObject
name: 'encryptionConfig'
description: |
Cloud Key Management Service (Cloud KMS) settings for a CMEK-protected cluster.
properties:
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
description: |
Describes the Cloud KMS encryption key that will be used to protect the destination Bigtable cluster. The requirements for this key are: 1) The Cloud Bigtable service account associated with the project that contains this cluster must be granted the `cloudkms.cryptoKeyEncrypterDecrypter` role on the CMEK key. 2) Only regional keys can be used and the region of the CMEK key must match the region of the cluster. Values are of the form `projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}`
15 changes: 15 additions & 0 deletions mmv1/products/bigtableadmin/inspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Provider::Inspec::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% project_instance_cluster = grab_attributes(pwd)['project_instance_cluster'] -%>
describe google_bigtableadmin_project_instance_cluster(name: <%= doc_generation ? "' #{project_instance_cluster['name']}'":"project_instance_cluster['name']" -%>) do
it { should exist }
its('name') { should cmp <%= doc_generation ? "'#{project_instance_cluster['name']}'" : "project_instance_cluster['name']" -%> }
its('location') { should cmp <%= doc_generation ? "'#{project_instance_cluster['location']}'" : "project_instance_cluster['location']" -%> }
its('state') { should cmp <%= doc_generation ? "'#{project_instance_cluster['state']}'" : "project_instance_cluster['state']" -%> }
its('default_storage_type') { should cmp <%= doc_generation ? "'#{project_instance_cluster['default_storage_type']}'" : "project_instance_cluster['default_storage_type']" -%> }

end

describe google_bigtableadmin_project_instance_cluster(name: "does_not_exit") do
it { should_not exist }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gcp_project_id = input(:gcp_project_id, value: '<%= external_attribute(pwd, 'gcp_project_id') -%>', description: 'The GCP project identifier.')

project_instance_cluster = input('project_instance_cluster', value: <%= JSON.pretty_generate(grab_attributes(pwd)['project_instance_cluster']) -%>, description: 'project_instance_cluster description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% gcp_project_id = "#{external_attribute(pwd, 'gcp_project_id', doc_generation)}" -%>
<% project_instance_cluster = grab_attributes(pwd)['project_instance_cluster'] -%>
describe google_bigtableadmin_project_instance_clusters(parent: <%= doc_generation ? "' #{project_instance_cluster['parent']}'":"project_instance_cluster['parent']" -%>) do
it { should exist }
end
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,14 @@ project_region_autoscaling_policy:
id : "value_id"



project_instance_cluster:
name : "value_name"
parent : "value_parent"
location : "value_location"
state : "value_state"
default_storage_type : "value_defaultstoragetype"

project_location_federation:
name : "value_name"
parent : "value_parent"
Expand All @@ -1234,6 +1242,7 @@ project_location_federation:
state : "value_state"
state_message : "value_statemessage"
uid : "value_uid"

project_location_service:
name : "value_name"
parent : "value_parent"
Expand All @@ -1247,4 +1256,4 @@ project_location_service:
tier : "value_tier"
uid : "value_uid"
release_channel : "value_releasechannel"
database_type : "value_databasetype"
database_type : "value_databasetype"

0 comments on commit 108b350

Please sign in to comment.