@@ -144,6 +144,140 @@ func TestSubscription_Create(t *testing.T) {
144
144
assert .Equal (t , expected , actual )
145
145
}
146
146
147
+ // tests CMK flow
148
+ func TestSubscription_CreateCMK (t * testing.T ) {
149
+ expected := 1235
150
+ s := httptest .NewServer (testServer ("key" , "secret" , postRequest (t , "/subscriptions" , `{
151
+ "name": "Test subscription",
152
+ "dryRun": false,
153
+ "paymentMethodId": 2,
154
+ "paymentMethod": "credit-card",
155
+ "memoryStorage": "ram",
156
+ "persistentStorageEncryptionType": "cloud-provider-managed-key",
157
+ "cloudProviders": [
158
+ {
159
+ "provider": "AWS",
160
+ "cloudAccountId": 1,
161
+ "regions": [
162
+ {
163
+ "region": "eu-west-1"
164
+ }
165
+ ]
166
+ }
167
+ ],
168
+ "databases": [
169
+ {
170
+ "name": "example",
171
+ "protocol": "redis",
172
+ "datasetSizeInGb": 1,
173
+ "supportOSSClusterApi": true,
174
+ "dataPersistence": "none",
175
+ "replication": false,
176
+ "throughputMeasurement": {
177
+ "by": "operations-per-second",
178
+ "value": 10000
179
+ },
180
+ "quantity": 1,
181
+ "queryPerformanceFactor": "4x"
182
+ }
183
+ ],
184
+ "redisVersion": "latest"
185
+ }` , `{
186
+ "taskId": "task-id",
187
+ "commandType": "subscriptionCreateRequest",
188
+ "status": "received",
189
+ "description": "Task request received and is being queued for processing.",
190
+ "timestamp": "2020-11-02T09:05:34.3Z",
191
+ "_links": {
192
+ "task": {
193
+ "href": "https://example.org",
194
+ "title": "getTaskStatusUpdates",
195
+ "type": "GET"
196
+ }
197
+ }
198
+ }` ), getRequestWithStatus (t , "/tasks/task-id" , 404 , "" ), getRequest (t , "/tasks/task-id" , `{
199
+ "taskId": "task-id",
200
+ "commandType": "subscriptionCreateRequest",
201
+ "status": "initialized",
202
+ "timestamp": "2020-10-28T09:58:16.798Z",
203
+ "response": {},
204
+ "_links": {
205
+ "self": {
206
+ "href": "https://example.com",
207
+ "type": "GET"
208
+ }
209
+ }
210
+ }` ), getRequest (t , "/tasks/task-id" , `{
211
+ "taskId": "task-id",
212
+ "commandType": "subscriptionCreateRequest",
213
+ "status": "processing-in-progress",
214
+ "timestamp": "2020-10-28T09:58:16.798Z",
215
+ "response": {},
216
+ "_links": {
217
+ "self": {
218
+ "href": "https://example.com",
219
+ "type": "GET"
220
+ }
221
+ }
222
+ }` ), getRequest (t , "/tasks/task-id" , fmt .Sprintf (`{
223
+ "taskId": "task-id",
224
+ "commandType": "subscriptionCreateRequest",
225
+ "status": "processing-completed",
226
+ "timestamp": "2020-10-28T09:58:16.798Z",
227
+ "response": {
228
+ "resourceId": %d
229
+ },
230
+ "_links": {
231
+ "self": {
232
+ "href": "https://example.com",
233
+ "type": "GET"
234
+ }
235
+ }
236
+ }` , expected ))))
237
+
238
+ subject , err := clientFromTestServer (s , "key" , "secret" )
239
+ require .NoError (t , err )
240
+
241
+ actual , err := subject .Subscription .Create (context .TODO (), subscriptions.CreateSubscription {
242
+ Name : redis .String ("Test subscription" ),
243
+ DryRun : redis .Bool (false ),
244
+ PaymentMethodID : redis .Int (2 ),
245
+ PaymentMethod : redis .String ("credit-card" ),
246
+ MemoryStorage : redis .String ("ram" ),
247
+ PersistentStorageEncryptionType : redis .String ("cloud-provider-managed-key" ),
248
+ CloudProviders : []* subscriptions.CreateCloudProvider {
249
+ {
250
+ Provider : redis .String ("AWS" ),
251
+ CloudAccountID : redis .Int (1 ),
252
+ Regions : []* subscriptions.CreateRegion {
253
+ {
254
+ Region : redis .String ("eu-west-1" ),
255
+ },
256
+ },
257
+ },
258
+ },
259
+ Databases : []* subscriptions.CreateDatabase {
260
+ {
261
+ Name : redis .String ("example" ),
262
+ Protocol : redis .String ("redis" ),
263
+ DatasetSizeInGB : redis .Float64 (1 ),
264
+ SupportOSSClusterAPI : redis .Bool (true ),
265
+ DataPersistence : redis .String ("none" ),
266
+ Replication : redis .Bool (false ),
267
+ ThroughputMeasurement : & subscriptions.CreateThroughput {
268
+ By : redis .String ("operations-per-second" ),
269
+ Value : redis .Int (10000 ),
270
+ },
271
+ Quantity : redis .Int (1 ),
272
+ QueryPerformanceFactor : redis .String ("4x" ),
273
+ },
274
+ },
275
+ RedisVersion : redis .String ("latest" ),
276
+ })
277
+ require .NoError (t , err )
278
+ assert .Equal (t , expected , actual )
279
+ }
280
+
147
281
func TestSubscription_List (t * testing.T ) {
148
282
s := httptest .NewServer (testServer ("apiKey" , "secret" , getRequest (t , "/subscriptions" , `{
149
283
"accountId": 53012,
0 commit comments