Skip to content

Commit 0c5c68e

Browse files
himanikhentertvl
authored andcommitted
memorystore open api (GoogleCloudPlatform#11463)
1 parent 2ff4ebe commit 0c5c68e

File tree

10 files changed

+930
-0
lines changed

10 files changed

+930
-0
lines changed
+343
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
---
2+
!ruby/object:Api::Resource
3+
base_url: "projects/{{project}}/locations/{{location}}/instances"
4+
create_url: "projects/{{project}}/locations/{{location}}/instances?instanceId={{instance_id}}"
5+
self_link: "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
6+
id_format: "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
7+
import_format:
8+
- "projects/{{project}}/locations/{{location}}/instances/{{instance_id}}"
9+
name: Instance
10+
description: A Google Cloud Memorystore instance.
11+
update_verb: :PATCH
12+
update_mask: true
13+
autogen_async: true
14+
min_version: beta
15+
timeouts: !ruby/object:Api::Timeouts
16+
insert_minutes: 60
17+
update_minutes: 120
18+
delete_minutes: 30
19+
custom_code: !ruby/object:Provider::Terraform::CustomCode
20+
encoder: templates/terraform/encoders/memorystore_instance.go.erb
21+
decoder: templates/terraform/decoders/memorystore_instance.go.erb
22+
examples:
23+
- !ruby/object:Provider::Terraform::Examples
24+
name: "memorystore_instance_basic"
25+
primary_resource_id: "instance-basic"
26+
min_version: beta
27+
vars:
28+
instance_name: "basic-instance"
29+
policy_name: "my-policy"
30+
subnet_name: "my-subnet"
31+
network_name: "my-network"
32+
prevent_destroy: "true"
33+
test_vars_overrides:
34+
prevent_destroy: "false"
35+
oics_vars_overrides:
36+
prevent_destroy: "false"
37+
- !ruby/object:Provider::Terraform::Examples
38+
name: "memorystore_instance_full"
39+
primary_resource_id: "instance-full"
40+
min_version: beta
41+
vars:
42+
instance_name: "full-instance"
43+
policy_name: "my-policy"
44+
subnet_name: "my-subnet"
45+
network_name: "my-network"
46+
prevent_destroy: "true"
47+
test_vars_overrides:
48+
prevent_destroy: "false"
49+
oics_vars_overrides:
50+
prevent_destroy: "false"
51+
- !ruby/object:Provider::Terraform::Examples
52+
name: "memorystore_instance_persistence_aof"
53+
primary_resource_id: "instance-persistence-aof"
54+
min_version: beta
55+
vars:
56+
instance_name: "aof-instance"
57+
policy_name: "my-policy"
58+
subnet_name: "my-subnet"
59+
network_name: "my-network"
60+
prevent_destroy: "true"
61+
test_vars_overrides:
62+
prevent_destroy: "false"
63+
oics_vars_overrides:
64+
prevent_destroy: "false"
65+
properties:
66+
- !ruby/object:Api::Type::String
67+
name: name
68+
description: "Identifier. Unique name of the instance.\nFormat: projects/{project}/locations/{location}/instances/{instance} "
69+
output: true
70+
- !ruby/object:Api::Type::String
71+
name: createTime
72+
description: "Output only. Creation timestamp of the instance. "
73+
output: true
74+
- !ruby/object:Api::Type::String
75+
name: updateTime
76+
description: "Output only. Latest update timestamp of the instance. "
77+
output: true
78+
- !ruby/object:Api::Type::KeyValueLabels
79+
name: labels
80+
description: "Optional. Labels to represent user-provided metadata. "
81+
- !ruby/object:Api::Type::String
82+
name: state
83+
description:
84+
"Output only. Current state of the instance. \n Possible values:\n
85+
CREATING\nACTIVE\nUPDATING\nDELETING"
86+
output: true
87+
- !ruby/object:Api::Type::NestedObject
88+
properties:
89+
- !ruby/object:Api::Type::NestedObject
90+
properties:
91+
- !ruby/object:Api::Type::Integer
92+
name: targetShardCount
93+
description: "Output only. Target number of shards for the instance. "
94+
output: true
95+
- !ruby/object:Api::Type::Integer
96+
name: targetReplicaCount
97+
description:
98+
"Output only. Target number of replica nodes per shard for the
99+
instance. "
100+
output: true
101+
name: updateInfo
102+
description: "Represents information about instance with state UPDATING. "
103+
output: true
104+
name: stateInfo
105+
description: "Additional information about the state of the instance. "
106+
output: true
107+
- !ruby/object:Api::Type::String
108+
name: uid
109+
description: "Output only. System assigned, unique identifier for the instance. "
110+
output: true
111+
- !ruby/object:Api::Type::Integer
112+
name: replicaCount
113+
description:
114+
"Optional. Number of replica nodes per shard. If omitted the default
115+
is 0 replicas. "
116+
default_from_api: true
117+
- !ruby/object:Api::Type::String
118+
name: authorizationMode
119+
description:
120+
"Optional. Immutable. Authorization mode of the instance. \n Possible
121+
values:\n AUTH_DISABLED\nIAM_AUTH"
122+
immutable: true
123+
default_from_api: true
124+
- !ruby/object:Api::Type::String
125+
name: transitEncryptionMode
126+
description:
127+
"Optional. Immutable. In-transit encryption mode of the instance. \n
128+
Possible values:\n TRANSIT_ENCRYPTION_DISABLED\nSERVER_AUTHENTICATION"
129+
immutable: true
130+
default_from_api: true
131+
- !ruby/object:Api::Type::Integer
132+
name: shardCount
133+
description: "Required. Number of shards for the instance. "
134+
required: true
135+
- !ruby/object:Api::Type::Array
136+
name: discoveryEndpoints
137+
item_type: !ruby/object:Api::Type::NestedObject
138+
properties:
139+
- !ruby/object:Api::Type::String
140+
name: address
141+
description:
142+
"Output only. IP address of the exposed endpoint clients connect
143+
to. "
144+
output: true
145+
- !ruby/object:Api::Type::Integer
146+
name: port
147+
description: "Output only. The port number of the exposed endpoint. "
148+
output: true
149+
- !ruby/object:Api::Type::String
150+
name: network
151+
description:
152+
"Output only. The network where the IP address of the discovery
153+
endpoint will be\nreserved, in the form of\nprojects/{network_project}/global/networks/{network_id}. "
154+
output: true
155+
description:
156+
"Output only. Endpoints clients can connect to the instance through.
157+
Currently only one\ndiscovery endpoint is supported. "
158+
output: true
159+
- !ruby/object:Api::Type::String
160+
name: nodeType
161+
description:
162+
"Optional. Immutable. Machine type for individual nodes of the instance.
163+
\n Possible values:\n SHARED_CORE_NANO\nHIGHMEM_MEDIUM\nHIGHMEM_XLARGE\nSTANDARD_SMALL"
164+
immutable: true
165+
default_from_api: true
166+
- !ruby/object:Api::Type::NestedObject
167+
properties:
168+
- !ruby/object:Api::Type::Enum
169+
name: mode
170+
description: "Optional. Current persistence mode. \n Possible values:\nDISABLED\nRDB\nAOF"
171+
values:
172+
- :DISABLED
173+
- :RDB
174+
- :AOF
175+
default_from_api: true
176+
- !ruby/object:Api::Type::NestedObject
177+
properties:
178+
- !ruby/object:Api::Type::String
179+
name: rdbSnapshotPeriod
180+
default_from_api: true
181+
description:
182+
"Optional. Period between RDB snapshots. \n Possible values:\n
183+
ONE_HOUR\nSIX_HOURS\nTWELVE_HOURS\nTWENTY_FOUR_HOURS"
184+
- !ruby/object:Api::Type::String
185+
name: rdbSnapshotStartTime
186+
description:
187+
"Optional. Time that the first snapshot was/will be attempted,
188+
and to which future\nsnapshots will be aligned. If not provided, the current
189+
time will be\nused. "
190+
default_from_api: true
191+
name: rdbConfig
192+
description: "Configuration for RDB based persistence. "
193+
default_from_api: true
194+
- !ruby/object:Api::Type::NestedObject
195+
properties:
196+
- !ruby/object:Api::Type::String
197+
name: appendFsync
198+
description: "Optional. The fsync mode. \n Possible values:\n NEVER\nEVERY_SEC\nALWAYS"
199+
default_from_api: true
200+
name: aofConfig
201+
description: "Configuration for AOF based persistence. "
202+
default_from_api: true
203+
name: persistenceConfig
204+
default_from_api: true
205+
description: "Represents persistence configuration for a instance. "
206+
- !ruby/object:Api::Type::String
207+
name: engineVersion
208+
description: "Optional. Immutable. Engine version of the instance. "
209+
immutable: true
210+
default_from_api: true
211+
- !ruby/object:Api::Type::KeyValuePairs
212+
name: engineConfigs
213+
description: "Optional. User-provided engine configurations for the instance. "
214+
- !ruby/object:Api::Type::NestedObject
215+
properties:
216+
- !ruby/object:Api::Type::Double
217+
name: sizeGb
218+
description: "Output only. Memory size in GB of the node. "
219+
output: true
220+
name: nodeConfig
221+
output: true
222+
description: "Represents configuration for nodes of the instance. "
223+
- !ruby/object:Api::Type::NestedObject
224+
properties:
225+
- !ruby/object:Api::Type::String
226+
name: zone
227+
description:
228+
"Optional. Defines zone where all resources will be allocated with
229+
SINGLE_ZONE mode.\nIgnored for MULTI_ZONE mode. "
230+
immutable: true
231+
- !ruby/object:Api::Type::Enum
232+
name: mode
233+
values:
234+
- :MULTI_ZONE
235+
- :SINGLE_ZONE
236+
default_from_api: true
237+
description:
238+
"Optional. Current zone distribution mode. Defaults to MULTI_ZONE.
239+
\n Possible values:\n MULTI_ZONE\nSINGLE_ZONE"
240+
name: zoneDistributionConfig
241+
immutable: true
242+
default_from_api: true
243+
description: "Zone distribution configuration for allocation of instance resources. "
244+
- !ruby/object:Api::Type::Boolean
245+
name: deletionProtectionEnabled
246+
description: "Optional. If set to true deletion of the instance will fail. "
247+
default_value: true
248+
- !ruby/object:Api::Type::Array
249+
name: pscAutoConnections
250+
item_type: !ruby/object:Api::Type::NestedObject
251+
properties:
252+
- !ruby/object:Api::Type::String
253+
name: pscConnectionId
254+
description:
255+
"Output only. The PSC connection id of the forwarding rule connected
256+
to the\nservice attachment. "
257+
output: true
258+
- !ruby/object:Api::Type::String
259+
name: ipAddress
260+
description:
261+
"Output only. The IP allocated on the consumer network for the
262+
PSC forwarding rule. "
263+
output: true
264+
- !ruby/object:Api::Type::String
265+
name: forwardingRule
266+
description: "Output only. The URI of the consumer side forwarding rule.\nFormat:\nprojects/{project}/regions/{region}/forwardingRules/{forwarding_rule} "
267+
output: true
268+
- !ruby/object:Api::Type::String
269+
name: projectId
270+
description:
271+
"Output only. The consumer project_id where the forwarding rule is
272+
created from. "
273+
output: true
274+
- !ruby/object:Api::Type::String
275+
name: network
276+
description:
277+
"Output only. The consumer network where the IP address resides, in
278+
the form of\nprojects/{project_id}/global/networks/{network_id}. "
279+
output: true
280+
description:
281+
"Output only. User inputs and resource details of the auto-created
282+
PSC connections. "
283+
output: true
284+
parameters:
285+
- !ruby/object:Api::Type::String
286+
name: location
287+
description:
288+
"Resource ID segment making up resource `name`. It identifies the resource
289+
within its parent collection as described in https://google.aip.dev/122. See documentation
290+
for resource type `memorystore.googleapis.com/CertificateAuthority`. "
291+
url_param_only: true
292+
required: true
293+
immutable: true
294+
- !ruby/object:Api::Type::String
295+
name: instanceId
296+
description:
297+
"Required. The ID to use for the instance, which will become the final
298+
component of\nthe instance's resource name.\n\nThis value is subject to the following
299+
restrictions:\n\n* Must be 4-63 characters in length\n* Must begin with a letter
300+
or digit\n* Must contain only lowercase letters, digits, and hyphens\n* Must not
301+
end with a hyphen\n* Must be unique within a location "
302+
url_param_only: true
303+
required: true
304+
immutable: true
305+
virtual_fields:
306+
- !ruby/object:Api::Type::Array
307+
name: desired_psc_auto_connections
308+
item_type: !ruby/object:Api::Type::NestedObject
309+
properties:
310+
- !ruby/object:Api::Type::String
311+
name: project_id
312+
description:
313+
"Required. The consumer project_id where the forwarding rule is
314+
created from. "
315+
required: true
316+
- !ruby/object:Api::Type::String
317+
name: network
318+
description:
319+
"Required. The consumer network where the IP address resides, in
320+
the form of\nprojects/{project_id}/global/networks/{network_id}. "
321+
required: true
322+
description: "Required. Immutable. User inputs for the auto-created
323+
PSC connections. "
324+
immutable: true
325+
required: true
326+
async: !ruby/object:Api::OpAsync
327+
operation: !ruby/object:Api::OpAsync::Operation
328+
path: name
329+
base_url: "{{op_id}}"
330+
wait_ms: 1000
331+
timeouts:
332+
result: !ruby/object:Api::OpAsync::Result
333+
path: response
334+
resource_inside_response: true
335+
status: !ruby/object:Api::OpAsync::Status
336+
path: done
337+
complete: true
338+
allowed:
339+
- true
340+
- false
341+
error: !ruby/object:Api::OpAsync::Error
342+
path: error
343+
message: message
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
!ruby/object:Api::Product
3+
versions:
4+
- !ruby/object:Api::Product::Version
5+
base_url: https://memorystore.googleapis.com/v1beta/
6+
name: beta
7+
name: Memorystore
8+
display_name: Memorystore
9+
scopes:
10+
- https://www.googleapis.com/auth/cloud-platform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Retrieve pscAutoConnections from API response
2+
v, ok := res["pscAutoConnections"]
3+
if !ok {
4+
return nil, fmt.Errorf("pscAutoConnections field not found in API response")
5+
}
6+
7+
connections, ok := v.([]interface{})
8+
if !ok {
9+
return nil, fmt.Errorf("pscAutoConnections is not an array")
10+
}
11+
12+
transformed := make([]interface{}, 0, len(connections))
13+
uniqueConnections := make(map[string]bool) // Track unique project+network combos
14+
15+
for _, raw := range connections {
16+
connectionData, ok := raw.(map[string]interface{})
17+
if !ok || len(connectionData) < 1 {
18+
return nil, fmt.Errorf("Invalid or empty psc connection data: %v", raw)
19+
}
20+
21+
projectID, ok := connectionData["projectId"].(string)
22+
if !ok {
23+
return nil, fmt.Errorf("invalid project ID in psc connection: %v", connectionData)
24+
}
25+
26+
networkID, ok := connectionData["network"].(string)
27+
if !ok {
28+
return nil, fmt.Errorf("invalid network ID in psc connection: %v", connectionData)
29+
}
30+
31+
uniqueKey := projectID + networkID
32+
if !uniqueConnections[uniqueKey] { // Check for uniqueness
33+
uniqueConnections[uniqueKey] = true
34+
transformed = append(transformed, map[string]interface{}{
35+
"project_id": projectID,
36+
"network": networkID,
37+
})
38+
}
39+
}
40+
41+
d.Set("desired_psc_auto_connections", transformed)
42+
return res, nil

0 commit comments

Comments
 (0)