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

memorystore open api #11463

Merged
merged 20 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
309 changes: 309 additions & 0 deletions mmv1/products/memorystore/Instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
---
!ruby/object:Api::Resource
base_url: "projects/{{project}}/locations/{{location}}/instances"
create_url: "projects/{{project}}/locations/{{location}}/instances?instanceId={{instance_id}}"
self_link: "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
id_format: "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
import_format:
- "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
name: Instance
description: A Google Cloud Memorystore instance.
update_verb: :PATCH
update_mask: true
autogen_async: true
min_version: beta
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/memorystore_instance.go.erb
himanikh marked this conversation as resolved.
Show resolved Hide resolved
decoder: templates/terraform/decoders/memorystore_instance.go.erb
examples:
- !ruby/object:Provider::Terraform::Examples
name: "memorystore_instance_ha"
primary_resource_id: "instance-ha"
min_version: beta
vars:
instance_name: "ha-instance"
policy_name: "mypolicy"
Copy link
Contributor

Choose a reason for hiding this comment

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

These variables should all include a hyphen, like my-policy, so that our generator adds the tf-test prefix behind the scenes, and these resources can be cleaned up if the test fails

subnet_name: "mysubnet"
network_name: "mynetwork"
prevent_destroy: "true"
test_vars_overrides:
prevent_destroy: "false"
oics_vars_overrides:
prevent_destroy: "false"
properties:
- !ruby/object:Api::Type::String
name: name
description: "Identifier. Unique name of the instance.\nFormat: projects/{project}/locations/{location}/instances/{instance} "
output: true
- !ruby/object:Api::Type::String
name: createTime
description: "Output only. Creation timestamp of the instance. "
output: true
- !ruby/object:Api::Type::String
name: updateTime
description: "Output only. Latest update timestamp of the instance. "
output: true
- !ruby/object:Api::Type::KeyValueLabels
name: labels
output:
api_name:
description: "Optional. Labels to represent user-provided metadata. "
min_version:
ignore_write:
update_verb:
update_url:
immutable:
- !ruby/object:Api::Type::String
name: state
description:
"Output only. Current state of the instance. \n Possible values:\n
STATE_UNSPECIFIED\nCREATING\nACTIVE\nUPDATING\nDELETING"
output: true
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::Integer
name: targetShardCount
description: "Output only. Target number of shards for the instance. "
output: true
- !ruby/object:Api::Type::Integer
name: targetReplicaCount
description:
"Output only. Target number of replica nodes per shard for the
instance. "
output: true
name: updateInfo
himanikh marked this conversation as resolved.
Show resolved Hide resolved
description: "Represents information about instance with state UPDATING. "
name: stateInfo
description: "Additional information about the state of the instance. "
- !ruby/object:Api::Type::String
name: uid
description: "Output only. System assigned, unique identifier for the instance. "
output: true
- !ruby/object:Api::Type::Integer
name: replicaCount
description:
"Optional. Number of replica nodes per shard. If omitted the default
is 0 replicas. "
default_from_api: true
- !ruby/object:Api::Type::String
name: authorizationMode
description:
"Optional. Immutable. Authorization mode of the instance. \n Possible
values:\n AUTHORIZATION_MODE_UNSPECIFIED\nAUTH_DISABLED\nIAM_AUTH"
immutable: true
default_from_api: true
- !ruby/object:Api::Type::String
name: transitEncryptionMode
description:
"Optional. Immutable. In-transit encryption mode of the instance. \n
Possible values:\n TRANSIT_ENCRYPTION_MODE_UNSPECIFIED\nTRANSIT_ENCRYPTION_DISABLED\nSERVER_AUTHENTICATION"
immutable: true
default_from_api: true
- !ruby/object:Api::Type::Integer
name: shardCount
description: "Required. Number of shards for the instance. "
required: true
- !ruby/object:Api::Type::Array
name: discoveryEndpoints
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: address
description:
"Output only. IP address of the exposed endpoint clients connect
to. "
output: true
- !ruby/object:Api::Type::Integer
name: port
description: "Output only. The port number of the exposed endpoint. "
output: true
- !ruby/object:Api::Type::String
name: network
description:
"Output only. The network where the IP address of the discovery
endpoint will be\nreserved, in the form of\nprojects/{network_project}/global/networks/{network_id}. "
output: true
description:
"Output only. Endpoints clients can connect to the instance through.
Currently only one\ndiscovery endpoint is supported. "
output: true
- !ruby/object:Api::Type::String
name: nodeType
description:
"Optional. Immutable. Machine type for individual nodes of the instance.
\n Possible values:\n NODE_TYPE_UNSPECIFIED\nSHARED_CORE_NANO\nHIGHMEM_MEDIUM\nHIGHMEM_XLARGE\nSTANDARD_SMALL"
himanikh marked this conversation as resolved.
Show resolved Hide resolved
immutable: true
default_from_api: true
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: mode
description: "Optional. Current persistence mode. \n Possible values:\n PERSISTENCE_MODE_UNSPECIFIED\nDISABLED\nRDB\nAOF"
default_from_api: true
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: rdbSnapshotPeriod
default_from_api: true
description:
"Optional. Period between RDB snapshots. \n Possible values:\n
SNAPSHOT_PERIOD_UNSPECIFIED\nONE_HOUR\nSIX_HOURS\nTWELVE_HOURS\nTWENTY_FOUR_HOURS"
- !ruby/object:Api::Type::String
name: rdbSnapshotStartTime
description:
"Optional. Time that the first snapshot was/will be attempted,
and to which future\nsnapshots will be aligned. If not provided, the current
time will be\nused. "
default_from_api: true
name: rdbConfig
description: "Configuration for RDB based persistence. "
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: appendFsync
description: "Optional. The fsync mode. \n Possible values:\n APPEND_FSYNC_UNSPECIFIED\nNEVER\nEVERY_SEC\nALWAYS"
default_from_api: true
name: aofConfig
description: "Configuration for AOF based persistence. "
name: persistenceConfig
description: "Represents persistence configuration for a instance. "
- !ruby/object:Api::Type::String
name: engineVersion
description: "Optional. Immutable. Engine version of the instance. "
immutable: true
default_from_api: true
- !ruby/object:Api::Type::KeyValuePairs
name: engineConfigs
output:
api_name:
description: "Optional. User-provided engine configurations for the instance. "
min_version:
ignore_write:
update_verb:
update_url:
immutable:
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::Double
name: sizeGb
description: "Output only. Memory size in GB of the node. "
output: true
name: nodeConfig
description: "Represents configuration for nodes of the instance. "
- !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: zone
description:
"Optional. Defines zone where all resources will be allocated with
SINGLE_ZONE mode.\nIgnored for MULTI_ZONE mode. "
- !ruby/object:Api::Type::String
name: mode
default_from_api: true
description:
"Optional. Current zone distribution mode. Defaults to MULTI_ZONE.
\n Possible values:\n ZONE_DISTRIBUTION_MODE_UNSPECIFIED\nMULTI_ZONE\nSINGLE_ZONE"
name: zoneDistributionConfig
description: "Zone distribution configuration for allocation of instance resources. "
- !ruby/object:Api::Type::Boolean
name: deletionProtectionEnabled
description: "Optional. If set to true deletion of the instance will fail. "
default_value: true
- !ruby/object:Api::Type::Array
name: pscAutoConnections
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: pscConnectionId
description:
"Output only. The PSC connection id of the forwarding rule connected
to the\nservice attachment. "
output: true
- !ruby/object:Api::Type::String
name: ipAddress
description:
"Output only. The IP allocated on the consumer network for the
PSC forwarding rule. "
output: true
- !ruby/object:Api::Type::String
name: forwardingRule
description: "Output only. The URI of the consumer side forwarding rule.\nFormat:\nprojects/{project}/regions/{region}/forwardingRules/{forwarding_rule} "
output: true
- !ruby/object:Api::Type::String
name: projectId
description:
"Output only. The consumer project_id where the forwarding rule is
created from. "
output: true
- !ruby/object:Api::Type::String
name: network
description:
"Output only. The consumer network where the IP address resides, in
the form of\nprojects/{project_id}/global/networks/{network_id}. "
output: true
description:
"Output only. User inputs and resource details of the auto-created
PSC connections. "
output: true
parameters:
- !ruby/object:Api::Type::String
name: location
description:
"Resource ID segment making up resource `name`. It identifies the resource
within its parent collection as described in https://google.aip.dev/122. See documentation
for resource type `memorystore.googleapis.com/CertificateAuthority`. "
url_param_only: true
required: true
immutable: true
- !ruby/object:Api::Type::String
name: instanceId
description:
"Required. The ID to use for the instance, which will become the final
component of\nthe instance's resource name.\n\nThis value is subject to the following
restrictions:\n\n* Must be 4-63 characters in length\n* Must begin with a letter
or digit\n* Must contain only lowercase letters, digits, and hyphens\n* Must not
end with a hyphen\n* Must be unique within a location "
url_param_only: true
required: true
immutable: true
virtual_fields:
- !ruby/object:Api::Type::Array
name: desired_psc_auto_connections
himanikh marked this conversation as resolved.
Show resolved Hide resolved
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: project_id
description:
"Required. The consumer project_id where the forwarding rule is
created from. "
required: true
- !ruby/object:Api::Type::String
name: network
description:
"Required. The consumer network where the IP address resides, in
the form of\nprojects/{project_id}/global/networks/{network_id}. "
required: true
description: "Required. Immutable. User inputs for the auto-created
PSC connections. "
immutable: true
required: true
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: name
base_url: "{{op_id}}"
wait_ms: 1000
timeouts:
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
10 changes: 10 additions & 0 deletions mmv1/products/memorystore/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
!ruby/object:Api::Product
versions:
- !ruby/object:Api::Product::Version
base_url: https://memorystore.googleapis.com/v1beta/
name: beta
name: Memorystore
display_name: Memorystore
scopes:
- https://www.googleapis.com/auth/cloud-platform
16 changes: 16 additions & 0 deletions mmv1/templates/terraform/decoders/memorystore_instance.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
v := res["psc_auto_connections"]
l := v.([]interface{})
transformed := make([]interface{}, 0, len(l))
for _, raw := range l {
original := raw.(map[string]interface{})
if len(original) < 1 {
// Do not include empty json objects coming back from the api
continue
}
transformed = append(transformed, map[string]interface{}{
"project_id": original["projectId"],
"network": original["network"],
})
}
d.Set("desired_psc_auto_connections", transformed)
return res, nil
27 changes: 27 additions & 0 deletions mmv1/templates/terraform/encoders/memorystore_instance.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
v, ok := d.GetOk("desired_psc_auto_connections")
if !ok {
return obj, nil // No desired connections, nothing to update
}
l := v.([]interface{})
req := make([]interface{}, 0, len(l))
for _, raw := range l {
if raw == nil {
continue
}
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedProjectId := original["project_id"]
if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["projectId"] = transformedProjectId
}

transformedNetwork := original["network"]
if val := reflect.ValueOf(transformedNetwork); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["network"] = transformedNetwork
}

req = append(req, transformed)
}
obj["psc_auto_connections"] = req
return obj, nil
Loading
Loading