Skip to content

Commit cd5f6dc

Browse files
Updates the VPCPeering model with additional attributes (#41)
* Updates the VPCPeering model with additional attributes covering GCP and AWS peering
1 parent 053a020 commit cd5f6dc

File tree

2 files changed

+85
-14
lines changed

2 files changed

+85
-14
lines changed

service/subscriptions/model.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,17 @@ type listVpcPeering struct {
178178
}
179179

180180
type VPCPeering struct {
181-
ID *int `json:"vpcPeeringId,omitempty"`
182-
Status *string `json:"status,omitempty"`
183-
AWSAccountID *string `json:"awsAccountId,omitempty"`
184-
VPCId *string `json:"vpcUid,omitempty"`
185-
VPCCidr *string `json:"vpcCidr,omitempty"`
186-
GCPProjectUID *string `json:"projectUid,omitempty"`
187-
NetworkName *string `json:"networkName,omitempty"`
181+
ID *int `json:"vpcPeeringId,omitempty"`
182+
Status *string `json:"status,omitempty"`
183+
AWSAccountID *string `json:"awsAccountId,omitempty"`
184+
AWSPeeringID *string `json:"awsPeeringUid,omitempty"`
185+
VPCId *string `json:"vpcUid,omitempty"`
186+
VPCCidr *string `json:"vpcCidr,omitempty"`
187+
GCPProjectUID *string `json:"projectUid,omitempty"`
188+
NetworkName *string `json:"networkName,omitempty"`
189+
RedisProjectUID *string `json:"redisProjectUid,omitempty"`
190+
RedisNetworkName *string `json:"redisNetworkName,omitempty"`
191+
CloudPeeringID *string `json:"cloudPeeringId,omitempty"`
188192
}
189193

190194
func (o VPCPeering) String() string {

subscription_test.go

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,16 @@ func TestSubscription_ListVPCPeering(t *testing.T) {
597597
"response": {
598598
"resourceId" : 12356,
599599
"resource" : {
600-
"peerings" : [ {
601-
"vpcPeeringId" : 10,
602-
"awsAccountId" : "4291",
603-
"vpcUid" : "vpc-deadbeef",
604-
"vpcCidr" : "10.0.0.0/24",
605-
"status" : "done"
606-
} ]
600+
"peerings" : [
601+
{
602+
"vpcPeeringId": 10,
603+
"awsAccountId": "4291",
604+
"vpcUid": "vpc-deadbeef",
605+
"vpcCidr": "10.0.0.0/24",
606+
"awsPeeringUid": "pcx-0123456789",
607+
"status": "done"
608+
}
609+
]
607610
}
608611
},
609612
"_links": {
@@ -626,11 +629,75 @@ func TestSubscription_ListVPCPeering(t *testing.T) {
626629
AWSAccountID: redis.String("4291"),
627630
VPCId: redis.String("vpc-deadbeef"),
628631
VPCCidr: redis.String("10.0.0.0/24"),
632+
AWSPeeringID: redis.String("pcx-0123456789"),
629633
Status: redis.String("done"),
630634
},
631635
}, actual)
632636
}
633637

638+
func TestSubscription_ListVPCPeering_gcp(t *testing.T) {
639+
s := httptest.NewServer(testServer("apiKey", "secret", getRequest(t, "/subscriptions/12356/peerings", `{
640+
"taskId": "task",
641+
"commandType": "peeringListRequest",
642+
"status": "received",
643+
"description": "Task request received and is being queued for processing.",
644+
"timestamp": "2020-11-02T09:05:34.3Z",
645+
"_links": {
646+
"task": {
647+
"href": "https://example.org",
648+
"title": "getTaskStatusUpdates",
649+
"type": "GET"
650+
}
651+
}
652+
}`), getRequest(t, "/tasks/task", `{
653+
"taskId": "task",
654+
"commandType": "vpcPeeringGetRequest",
655+
"status": "processing-completed",
656+
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.",
657+
"timestamp": "2020-12-01T14:56:09.204Z",
658+
"response": {
659+
"resourceId": 12356,
660+
"resource": {
661+
"peerings": [
662+
{
663+
"vpcPeeringId": 11,
664+
"projectUid": "cloud-api-123456",
665+
"networkName": "cloud-api-vpc-peering-test",
666+
"redisProjectUid": "v00d1c1f22233333f-tp",
667+
"redisNetworkName": "c12345-us-east1-2-rlrcp",
668+
"cloudPeeringId": "redislabs-peering-f123abc4-d56",
669+
"status": "inactive"
670+
}
671+
]
672+
}
673+
},
674+
"_links": {
675+
"self": {
676+
"href": "https://example.com",
677+
"type": "GET"
678+
}
679+
}
680+
}`)))
681+
682+
subject, err := clientFromTestServer(s, "apiKey", "secret")
683+
require.NoError(t, err)
684+
685+
actual, err := subject.Subscription.ListVPCPeering(context.TODO(), 12356)
686+
require.NoError(t, err)
687+
688+
assert.ElementsMatch(t, []*subscriptions.VPCPeering{
689+
{
690+
ID: redis.Int(11),
691+
Status: redis.String("inactive"),
692+
GCPProjectUID: redis.String("cloud-api-123456"),
693+
NetworkName: redis.String("cloud-api-vpc-peering-test"),
694+
RedisProjectUID: redis.String("v00d1c1f22233333f-tp"),
695+
RedisNetworkName: redis.String("c12345-us-east1-2-rlrcp"),
696+
CloudPeeringID: redis.String("redislabs-peering-f123abc4-d56"),
697+
},
698+
}, actual)
699+
}
700+
634701
func TestSubscription_CreateVPCPeering(t *testing.T) {
635702
expected := 1235
636703
s := httptest.NewServer(testServer("key", "secret", postRequest(t, "/subscriptions/42/peerings", `{

0 commit comments

Comments
 (0)