Skip to content

Commit d622259

Browse files
Merge pull request #236 from RedisLabs/feat/public-endpoint-access
Public Endpoint Access
2 parents b87bd09 + 1298da1 commit d622259

File tree

4 files changed

+243
-2
lines changed

4 files changed

+243
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,5 @@ vendor
275275

276276
CLAUDE.md
277277
.claude
278+
279+
coverage.out

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
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+
6+
## 0.38.0 (15th October 2025)
7+
8+
### Added:
9+
* Added `PublicEndpointAccess` field to Subscription create/update API
10+
* New tests to check this field is used correctly
11+
512
## 0.37.0 (8th October 2025)
613

714
### Added:

service/subscriptions/model.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type CreateSubscription struct {
1717
Databases []*CreateDatabase `json:"databases,omitempty"`
1818
RedisVersion *string `json:"redisVersion,omitempty"`
1919
PersistentStorageEncryptionType *string `json:"persistentStorageEncryptionType,omitempty"`
20+
PublicEndpointAccess *bool `json:"publicEndpointAccess,omitempty"`
2021
}
2122

2223
func (o CreateSubscription) String() string {
@@ -101,8 +102,9 @@ func (o CreateModules) String() string {
101102
}
102103

103104
type UpdateSubscription struct {
104-
Name *string `json:"name,omitempty"`
105-
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
105+
Name *string `json:"name,omitempty"`
106+
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
107+
PublicEndpointAccess *bool `json:"publicEndpointAccess,omitempty"`
106108
}
107109

108110
func (o UpdateSubscription) String() string {
@@ -135,6 +137,7 @@ type Subscription struct {
135137
NumberOfDatabases *int `json:"numberOfDatabases,omitempty"`
136138
CloudDetails []*CloudDetail `json:"cloudDetails,omitempty"`
137139
CustomerManagedKeyAccessDetails *CustomerManagedKeyAccessDetails `json:"customerManagedKeyAccessDetails,omitempty"`
140+
PublicEndpointAccess *bool `json:"publicEndpointAccess,omitempty"`
138141
}
139142

140143
type CustomerManagedKeyAccessDetails struct {

subscription_test.go

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
148253
func 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+
541726
func 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+
553782
func TestSubscription_Update(t *testing.T) {
554783
s := httptest.NewServer(testServer("key", "secret", putRequest(t, "/subscriptions/1234", `{
555784
"name": "test",

0 commit comments

Comments
 (0)