Skip to content

Commit 1a79923

Browse files
Merge pull request #209 from RedisLabs/feat/OPCR-6-persistent-storage-encryption-type
OPCR-6:Persistent storage encryption type
2 parents 0fb88b8 + e0f2ffb commit 1a79923

File tree

3 files changed

+150
-9
lines changed

3 files changed

+150
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to this project will be documented in this file.
33
See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/).
44

5+
## 0.30.0
6+
7+
### Added
8+
9+
* Adding in support for `persistentStorageEncryptionType`, to support CMEK, across pro and active active subscription creation
10+
511
## 0.29.0
612

713
### Added

service/subscriptions/model.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import (
77
)
88

99
type CreateSubscription struct {
10-
Name *string `json:"name,omitempty"`
11-
DeploymentType *string `json:"deploymentType,omitempty"`
12-
DryRun *bool `json:"dryRun,omitempty"`
13-
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
14-
PaymentMethod *string `json:"paymentMethod,omitempty"`
15-
MemoryStorage *string `json:"memoryStorage,omitempty"`
16-
CloudProviders []*CreateCloudProvider `json:"cloudProviders,omitempty"`
17-
Databases []*CreateDatabase `json:"databases,omitempty"`
18-
RedisVersion *string `json:"redisVersion,omitempty"`
10+
Name *string `json:"name,omitempty"`
11+
DeploymentType *string `json:"deploymentType,omitempty"`
12+
DryRun *bool `json:"dryRun,omitempty"`
13+
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
14+
PaymentMethod *string `json:"paymentMethod,omitempty"`
15+
MemoryStorage *string `json:"memoryStorage,omitempty"`
16+
CloudProviders []*CreateCloudProvider `json:"cloudProviders,omitempty"`
17+
Databases []*CreateDatabase `json:"databases,omitempty"`
18+
RedisVersion *string `json:"redisVersion,omitempty"`
19+
PersistentStorageEncryptionType *string `json:"persistentStorageEncryptionType,omitempty"`
1920
}
2021

2122
func (o CreateSubscription) String() string {

subscription_test.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,140 @@ func TestSubscription_Create(t *testing.T) {
144144
assert.Equal(t, expected, actual)
145145
}
146146

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+
147281
func TestSubscription_List(t *testing.T) {
148282
s := httptest.NewServer(testServer("apiKey", "secret", getRequest(t, "/subscriptions", `{
149283
"accountId": 53012,

0 commit comments

Comments
 (0)