@@ -144,6 +144,111 @@ func TestSubscription_Create(t *testing.T) {
144144 assert .Equal (t , expected , actual )
145145}
146146
147+ func TestSubscription_Create_PublicEndpointAccess (t * testing.T ) {
148+ expected := 1236
149+ s := httptest .NewServer (testServer ("key" , "secret" , postRequest (t , "/subscriptions" , `{
150+ "name": "Test subscription",
151+ "dryRun": false,
152+ "paymentMethodId": 2,
153+ "paymentMethod": "credit-card",
154+ "memoryStorage": "ram",
155+ "publicEndpointAccess": false,
156+ "cloudProviders": [
157+ {
158+ "provider": "AWS",
159+ "cloudAccountId": 1,
160+ "regions": [
161+ {
162+ "region": "eu-west-1"
163+ }
164+ ]
165+ }
166+ ],
167+ "databases": [
168+ {
169+ "name": "example",
170+ "protocol": "redis",
171+ "datasetSizeInGb": 1,
172+ "supportOSSClusterApi": true,
173+ "dataPersistence": "none",
174+ "replication": false,
175+ "throughputMeasurement": {
176+ "by": "operations-per-second",
177+ "value": 10000
178+ },
179+ "quantity": 1
180+ }
181+ ]
182+ }` , `{
183+ "taskId": "task-id",
184+ "commandType": "subscriptionCreateRequest",
185+ "status": "received",
186+ "description": "Task request received and is being queued for processing.",
187+ "timestamp": "2020-11-02T09:05:34.3Z",
188+ "_links": {
189+ "task": {
190+ "href": "https://example.org",
191+ "title": "getTaskStatusUpdates",
192+ "type": "GET"
193+ }
194+ }
195+ }` ), getRequest (t , "/tasks/task-id" , fmt .Sprintf (`{
196+ "taskId": "task-id",
197+ "commandType": "subscriptionCreateRequest",
198+ "status": "processing-completed",
199+ "timestamp": "2020-10-28T09:58:16.798Z",
200+ "response": {
201+ "resourceId": %d
202+ },
203+ "_links": {
204+ "self": {
205+ "href": "https://example.com",
206+ "type": "GET"
207+ }
208+ }
209+ }` , expected ))))
210+
211+ subject , err := clientFromTestServer (s , "key" , "secret" )
212+ require .NoError (t , err )
213+
214+ actual , err := subject .Subscription .Create (context .TODO (), subscriptions.CreateSubscription {
215+ Name : redis .String ("Test subscription" ),
216+ DryRun : redis .Bool (false ),
217+ PaymentMethodID : redis .Int (2 ),
218+ PaymentMethod : redis .String ("credit-card" ),
219+ MemoryStorage : redis .String ("ram" ),
220+ PublicEndpointAccess : redis .Bool (false ),
221+ CloudProviders : []* subscriptions.CreateCloudProvider {
222+ {
223+ Provider : redis .String ("AWS" ),
224+ CloudAccountID : redis .Int (1 ),
225+ Regions : []* subscriptions.CreateRegion {
226+ {
227+ Region : redis .String ("eu-west-1" ),
228+ },
229+ },
230+ },
231+ },
232+ Databases : []* subscriptions.CreateDatabase {
233+ {
234+ Name : redis .String ("example" ),
235+ Protocol : redis .String ("redis" ),
236+ DatasetSizeInGB : redis .Float64 (1 ),
237+ SupportOSSClusterAPI : redis .Bool (true ),
238+ DataPersistence : redis .String ("none" ),
239+ Replication : redis .Bool (false ),
240+ ThroughputMeasurement : & subscriptions.CreateThroughput {
241+ By : redis .String ("operations-per-second" ),
242+ Value : redis .Int (10000 ),
243+ },
244+ Quantity : redis .Int (1 ),
245+ },
246+ },
247+ })
248+ require .NoError (t , err )
249+ assert .Equal (t , expected , actual )
250+ }
251+
147252// tests CMK flow
148253func TestSubscription_CreateCMK (t * testing.T ) {
149254 expected := 1235
@@ -538,6 +643,86 @@ func TestSubscription_Get(t *testing.T) {
538643 }, actual )
539644}
540645
646+ func TestSubscription_Get_PublicEndpointAccess (t * testing.T ) {
647+ s := httptest .NewServer (testServer ("apiKey" , "secret" , getRequest (t , "/subscriptions/98766" , `{
648+ "id": 2,
649+ "name": "Get-test-public-endpoint",
650+ "status": "active",
651+ "paymentMethodType": "credit-card",
652+ "paymentMethodId": 2,
653+ "memoryStorage": "ram",
654+ "storageEncryption": false,
655+ "publicEndpointAccess": false,
656+ "numberOfDatabases": 1,
657+ "cloudDetails": [
658+ {
659+ "provider": "AWS",
660+ "cloudAccountId": 3,
661+ "totalSizeInGb": 4,
662+ "regions": [
663+ {
664+ "region": "eu-west-1",
665+ "networking": [
666+ {
667+ "deploymentCIDR": "10.0.0.0/24",
668+ "subnetId": "subnet-123456"
669+ }
670+ ],
671+ "preferredAvailabilityZones": [
672+ "eu-west-1a"
673+ ],
674+ "multipleAvailabilityZones": false
675+ }
676+ ]
677+ }
678+ ],
679+ "_links": {
680+ "self": {
681+ "href": "https://example.com",
682+ "type": "GET"
683+ }
684+ }
685+ }` )))
686+
687+ subject , err := clientFromTestServer (s , "apiKey" , "secret" )
688+ require .NoError (t , err )
689+
690+ actual , err := subject .Subscription .Get (context .TODO (), 98766 )
691+ require .NoError (t , err )
692+
693+ assert .Equal (t , & subscriptions.Subscription {
694+ ID : redis .Int (2 ),
695+ Name : redis .String ("Get-test-public-endpoint" ),
696+ Status : redis .String ("active" ),
697+ PaymentMethod : redis .String ("credit-card" ),
698+ PaymentMethodID : redis .Int (2 ),
699+ MemoryStorage : redis .String ("ram" ),
700+ StorageEncryption : redis .Bool (false ),
701+ PublicEndpointAccess : redis .Bool (false ),
702+ NumberOfDatabases : redis .Int (1 ),
703+ CloudDetails : []* subscriptions.CloudDetail {
704+ {
705+ Provider : redis .String ("AWS" ),
706+ CloudAccountID : redis .Int (3 ),
707+ TotalSizeInGB : redis .Float64 (4 ),
708+ Regions : []* subscriptions.Region {
709+ {
710+ Region : redis .String ("eu-west-1" ),
711+ Networking : []* subscriptions.Networking {
712+ {
713+ DeploymentCIDR : redis .String ("10.0.0.0/24" ),
714+ SubnetID : redis .String ("subnet-123456" ),
715+ },
716+ },
717+ PreferredAvailabilityZones : redis .StringSlice ("eu-west-1a" ),
718+ MultipleAvailabilityZones : redis .Bool (false ),
719+ },
720+ },
721+ },
722+ },
723+ }, actual )
724+ }
725+
541726func TestSubscription_Get_wraps404Error (t * testing.T ) {
542727 s := httptest .NewServer (testServer ("apiKey" , "secret" , getRequestWithStatus (t , "/subscriptions/123" , 404 , "" )))
543728
@@ -550,6 +735,50 @@ func TestSubscription_Get_wraps404Error(t *testing.T) {
550735 assert .IsType (t , & subscriptions.NotFound {}, err )
551736}
552737
738+ func TestSubscription_Update_PublicEndpointAccess (t * testing.T ) {
739+ s := httptest .NewServer (testServer ("key" , "secret" , putRequest (t , "/subscriptions/1234" , `{
740+ "name": "test",
741+ "paymentMethodId": 7,
742+ "publicEndpointAccess": false
743+ }` , `{
744+ "taskId": "task",
745+ "commandType": "subscriptionUpdateRequest",
746+ "status": "received",
747+ "description": "Task request received and is being queued for processing.",
748+ "timestamp": "2020-11-02T09:05:34.3Z",
749+ "_links": {
750+ "task": {
751+ "href": "https://example.org",
752+ "title": "getTaskStatusUpdates",
753+ "type": "GET"
754+ }
755+ }
756+ }` ), getRequest (t , "/tasks/task" , `{
757+ "taskId": "e02b40d6-1395-4861-a3b9-ecf829d835fd",
758+ "commandType": "subscriptionUpdateRequest",
759+ "status": "processing-completed",
760+ "timestamp": "2020-10-28T09:58:16.798Z",
761+ "response": {
762+ },
763+ "_links": {
764+ "self": {
765+ "href": "https://example.com",
766+ "type": "GET"
767+ }
768+ }
769+ }` )))
770+
771+ subject , err := clientFromTestServer (s , "key" , "secret" )
772+ require .NoError (t , err )
773+
774+ err = subject .Subscription .Update (context .TODO (), 1234 , subscriptions.UpdateSubscription {
775+ Name : redis .String ("test" ),
776+ PaymentMethodID : redis .Int (7 ),
777+ PublicEndpointAccess : redis .Bool (false ),
778+ })
779+ require .NoError (t , err )
780+ }
781+
553782func TestSubscription_Update (t * testing.T ) {
554783 s := httptest .NewServer (testServer ("key" , "secret" , putRequest (t , "/subscriptions/1234" , `{
555784 "name": "test",
0 commit comments