Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated storage_pool #9229

Merged
merged 17 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mmv1/products/netapp/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018 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:Api::Product
name: Netapp
display_name: Netapp
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://netapp.googleapis.com/v1/
- !ruby/object:Api::Product::Version
name: beta
base_url: https://netapp.googleapis.com/v1beta1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Cloud Volume API
url: https://console.cloud.google.com/apis/library/cloudvolumesgcp-api.netapp.com
227 changes: 227 additions & 0 deletions mmv1/products/netapp/storagePool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# Copyright 2023 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:Api::Resource
# API resource name
name: 'storagePool'
# Resource description for the provider documentation.
description: |
StoragePool is a container for volumes with a service level and capacity.
Volumes can be created in a pool of sufficient available capacity. StoragePool capacity is what you are billed for.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'QUICKSTART_TITLE': 'https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.storagePools'
# Link to the REST API reference for the resource. For example,
api: 'https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.storagePools'
# Marks the resource as beta-only. Ensure a beta version block is present in
# provider.yaml.
# min_version: beta

# Inserts styled markdown into the header of the resource's page in the
# provider documentation.
# docs: !ruby/object:Provider::Terraform::Docs
# warning: |
# MULTILINE_WARNING_MARKDOWN
# note: |
# MULTILINE_NOTE_MARKDOWN

# URL for the resource's standard List method. https://google.aip.dev/132
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
base_url: projects/{{project}}/locations/{{location}}/storagePools
# URL for the resource's standard Get method. https://google.aip.dev/131
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
self_link: projects/{{project}}/locations/{{location}}/storagePools/{{storage_pool_id}}

# If true, the resource and all its fields are considered immutable - that is,
# only creatable, not updatable. Individual fields can override this if they
# have a custom update method in the API.
# immutable: true

# Overrides one or more timeouts, in minutes. All timeouts default to 20.
# timeouts: !ruby/object:Api::Timeouts
# insert_minutes: 20
# update_minutes: 20
# delete_minutes: 20

# URL for the resource's standard Create method, including query parameters.
# https://google.aip.dev/133
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
create_url: projects/{{project}}/locations/{{location}}/storagePools?storagePoolId={{storage_pool_id}}
# Overrides the HTTP verb used to create a new resource.
# Allowed values: :POST, :PUT, :PATCH. Default: :POST
create_verb: :POST
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the default ones, I think we can omit them from this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the Create/Delete verb. Update verb was not default, hence keeping it.


# Overrides the URL for the resource's standard Update method. (If unset, the
# self_link URL is used by default.) https://google.aip.dev/134
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
update_url: projects/{{project}}/locations/{{location}}/storagePools/{{storage_pool_id}}
# The HTTP verb used to update a resource. Allowed values: :POST, :PUT, :PATCH. Default: :PUT.
update_verb: :PATCH
# If true, the resource sets an `updateMask` query parameter listing modified
# fields when updating the resource. If false, it does not.
update_mask: true

# Overrides the URL for the resource's standard Delete method. (If unset, the
# self_link URL is used by default.) https://google.aip.dev/135
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
delete_url: projects/{{project}}/locations/{{location}}/storagePools/{{storage_pool_id}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
delete_url: projects/{{project}}/locations/{{location}}/storagePools/{{storage_pool_id}}
delete_url: projects/{{project}}/locations/{{location}}/storagePools/{{name}}

# Overrides the HTTP verb used to delete a resource.
# Allowed values: :POST, :PUT, :PATCH, :DELETE. Default: :DELETE
delete_verb: :DELETE

# If true, code for handling long-running operations is generated along with
# the resource. If false, that code is not generated.
autogen_async: true
# Sets parameters for handling operations returned by the API.
async: !ruby/object:Api::OpAsync
# Overrides which API calls return operations. Default: ['create',
# 'update', 'delete']
# actions: ['create', 'update', 'delete']
operation: !ruby/object:Api::OpAsync::Operation
base_url: '{{op_id}}'

# If true, the provider sets the resource's Terraform ID after the resource is created,
# taking into account values that are set by the API at create time. This is only possible
# when the completed operation's JSON includes the created resource in the "response" field.
# If false (or unset), the provider sets the resource's Terraform ID before the resource is
# created, based only on the resource configuration.
# result: !ruby/object:Api::OpAsync::Result
# resource_inside_response: true

# All resources (of all kinds) that share a mutex value block rather than
# executing concurrent API requests.
# Terraform field names enclosed in double curly braces are replaced with
# the field values from the resource at runtime.
# mutex: RESOURCE_NAME/{{name}}

parameters:
- !ruby/object:Api::Type::String
name: 'location'
required: true
immutable: true
url_param_only: true
description: |
LOCATION_DESCRIPTION
- !ruby/object:Api::Type::String
name: 'storage_pool_id'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'storage_pool_id'
name: 'name'

description:
'The unique name of the storage pool
`[_a-zA-Z0-9][-_.a-zA-Z0-9]*`.'
required: true
immutable: true
url_param_only: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'Storage_pool_create'
primary_resource_id: 'test_pool'
vars:
pool_name: 'test-pool'
properties:
# Fields go here
- !ruby/object:Api::Type::String
name: name
output: true
description: |
Name of the storage pool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- !ruby/object:Api::Type::String
name: name
output: true
description: |
Name of the storage pool

If users want to the long form identifier, they can use id instead

- !ruby/object:Api::Type::Enum
name: 'serviceLevel'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
Service level of the storage pool
values:
- :PREMIUM
- :EXTREME
- :STANDARD
- !ruby/object:Api::Type::String
name: 'capacityGib'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
Capacity in GIB of the pool
- !ruby/object:Api::Type::String
name: 'volumeCapacityGib'
description: |
Allocated size of all volumes in GIB in the storage pool
output: true
- !ruby/object:Api::Type::Integer
name: 'volumeCount'
description: |
Volume count of the storage pool
output: true
- !ruby/object:Api::Type::Enum
name: 'State'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually fields like state, stateDetails and createTime are not useful to Terraform users that we can omit from implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the above fields from yaml.

description: |
State of the storage pool
values:
- :STATE_UNSPECIFIED
- :CREATING
- :RESTORING
- :UPDATING
- :DELETING
- :DISABLED
- :READY
output: true
- !ruby/object:Api::Type::String
name: 'stateDetails'
description: |
State details of the storage pool
output: true
- !ruby/object:Api::Type::String
name: 'createTime'
description: |
Create time of the storage pool
output: true
- !ruby/object:Api::Type::String
name: 'description'
description: |
Description of the storage pool
- !ruby/object:Api::Type::KeyValuePairs
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
name: labels
description: |
Labels as key value pairs.An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
- !ruby/object:Api::Type::String
name: 'network'
G-NamanGupta marked this conversation as resolved.
Show resolved Hide resolved
description: |
VPC Network name. Format: projects/{project}/global/networks/{network}
diff_suppress_func: tpgresource.ProjectNumberDiffSuppress
shuyama1 marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::String
name: 'activeDirectory'
description: |
Specifies the Active Directory to be used for creating a SMB volume.
- !ruby/object:Api::Type::String
name: 'kmsConfig'
description: |
Specifies the KMS config to be used for volume encryption.
- !ruby/object:Api::Type::Boolean
name: 'ldapEnabled'
description: |
Flag indicating if the pool is NFS LDAP enabled or not.
- !ruby/object:Api::Type::String
name: 'psaRange'
description: |
Name of the Private Service Access allocated range. If not provided, any available range will be chosen.
- !ruby/object:Api::Type::Enum
name: 'encryptionType'
description: |
Specifies the current pool encryption key source.
values:
- :ENCRYPTION_TYPE_UNSPECIFIED
- :SERVICE_MANAGED
- :CLOUD_KMS
output: true
- !ruby/object:Api::Type::Boolean
name: 'globalAccessAllowed'
description: |
Allows SO pool to access AD or DNS server from other regions.
37 changes: 37 additions & 0 deletions mmv1/templates/terraform/examples/Storage_pool_create.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

resource "google_compute_network" "peering_network" {
name = "peering-network"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for identifiers of resources in the tests, generally name field, we need to use variables instead of hardcoded value, so our generator will add tf-test as prefix for sweepers and random characters as suffix, which to avoid interacting with same resources among different tests.
Please see step 4 in https://googlecloudplatform.github.io/magic-modules/develop/test/#add-a-create-test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the field to take value from a variable from yaml file.

}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
name = "private-ip-alloc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the field to take value from a variable from yaml file.

purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
network = google_compute_network.peering_network.id
service = "netapp.servicenetworking.goog"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

resource "google_netapp_storage_pool" "test_pool" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resource "google_netapp_storage_pool" "test_pool" {
resource "google_netapp_storage_pool" "<%= ctx[:primary_resource_id] %>" {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the suggestion.

storage_pool_id = "testpool1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
storage_pool_id = "testpool1"
storage_pool_id = "<%= ctx[:vars]['pool_name'] %>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the suggestion.

location = "us-central1"
service_level = "PREMIUM"
capacity_gib = "2048"
network = google_compute_network.peering_network.id
active_directory = ""
description = ""
global_access_allowed = false
kms_config = ""
labels = {}
ldap_enabled = false
psa_range = ""
shuyama1 marked this conversation as resolved.
Show resolved Hide resolved

}

Loading