Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions service/regions/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ type Database struct {
}

type CreateRegion struct {
Region *string `json:"region,omitempty"`
DeploymentCIDR *string `json:"deploymentCIDR,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`
RespVersion *string `json:"respVersion,omitempty"`
Databases []*CreateDatabase `json:"databases,omitempty"`
Region *string `json:"region,omitempty"`
DeploymentCIDR *string `json:"deploymentCIDR,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`
RespVersion *string `json:"respVersion,omitempty"`
VpcId *string `json:"vpcId,omitempty"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed with this PR that we're being inconsistent across the codebase with how we capitalise ID in the various fields. No change necessarily needed with this PR but it might be nice to go across the codebase, pick a convention, and stick to it (in future)

SubnetIds []*string `json:"subnetIds,omitempty"`
SecurityGroupId *string `json:"securityGroupId,omitempty"`
Databases []*CreateDatabase `json:"databases,omitempty"`
}

type DeleteRegion struct {
Expand Down
35 changes: 33 additions & 2 deletions service/subscriptions/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func (o CreateRegion) String() string {
}

type CreateNetworking struct {
DeploymentCIDR *string `json:"deploymentCIDR,omitempty"`
VPCId *string `json:"vpcId,omitempty"`
DeploymentCIDR *string `json:"deploymentCIDR,omitempty"`
VPCId *string `json:"vpcId,omitempty"`
SubnetIds []*string `json:"subnetIds,omitempty"`
SecurityGroupId *string `json:"securityGroupId,omitempty"`
}

func (o CreateNetworking) String() string {
Expand Down Expand Up @@ -143,6 +145,31 @@ type Subscription struct {
PublicEndpointAccess *bool `json:"publicEndpointAccess,omitempty"`
}

type ActiveActiveSubscription struct {
ID *int `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Status *string `json:"status,omitempty"`
DeploymentType *string `json:"deploymentType,omitempty"`
PaymentMethod *string `json:"paymentMethodType,omitempty"`
PaymentMethodID *int `json:"paymentMethodId,omitempty"`
MemoryStorage *string `json:"memoryStorage,omitempty"`
StorageEncryption *bool `json:"storageEncryption,omitempty"`
NumberOfDatabases *int `json:"numberOfDatabases,omitempty"`
CloudDetails []*ActiveActiveCloudDetail `json:"cloudDetails,omitempty"`
PersistentStorageEncryptionType *string `json:"persistentStorageEncryptionType,omitempty"`
DeletionGracePeriod *string `json:"deletionGracePeriod,omitempty"`
CustomerManagedKeyAccessDetails *CustomerManagedKeyAccessDetails `json:"customerManagedKeyAccessDetails,omitempty"`
PublicEndpointAccess *bool `json:"publicEndpointAccess,omitempty"`
}

type ActiveActiveCloudDetail struct {
Provider *string `json:"provider,omitempty"`
CloudAccountID *int `json:"cloudAccountId,omitempty"`
AWSAccountID *string `json:"awsAccountId,omitempty"`
TotalSizeInGB *float64 `json:"totalSizeInGb,omitempty"`
Regions []*ActiveActiveRegion `json:"regions,omitempty"`
}

type CustomerManagedKeyAccessDetails struct {
RedisServiceAccount *string `json:"redisServiceAccount,omitempty"`
GooglePredefinedRoles []*string `json:"googlePredefinedRoles,omitempty"`
Expand Down Expand Up @@ -307,6 +334,10 @@ type listSubscriptionResponse struct {
Subscriptions []*Subscription `json:"subscriptions"`
}

type listActiveActiveSubscriptionResponse struct {
Subscriptions []*ActiveActiveSubscription `json:"subscriptions"`
}

type ListAASubscriptionRegionsResponse struct {
SubscriptionId *int `json:"subscriptionId,omitempty"`
Regions []*ActiveActiveRegion `json:"regions"`
Expand Down
27 changes: 27 additions & 0 deletions service/subscriptions/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ func (a *API) List(ctx context.Context) ([]*Subscription, error) {
return response.Subscriptions, nil
}

// ListActiveActive will list all of the current account's active-active subscriptions.
func (a *API) ListActiveActive(ctx context.Context) ([]*ActiveActiveSubscription, error) {
var response listActiveActiveSubscriptionResponse
err := a.client.Get(ctx, "list subscriptions", "/subscriptions", &response)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should change the comment to "list active active subscriptions" to be explicit

if err != nil {
return nil, err
}
var activeActiveSubscriptions []*ActiveActiveSubscription
for _, sub := range response.Subscriptions {
if *sub.DeploymentType == "active-active" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll probably want to do a nilcheck on DeploymentType before referencing it

if sub.DeploymentType != nil && *sub.DeploymentType == SubscriptionDeploymentTypeActiveActive {  

activeActiveSubscriptions = append(activeActiveSubscriptions, sub)
}
}
return activeActiveSubscriptions, nil
}

// Get will retrieve an existing subscription.
func (a *API) Get(ctx context.Context, id int) (*Subscription, error) {
var response Subscription
Expand All @@ -76,6 +92,17 @@ func (a *API) Get(ctx context.Context, id int) (*Subscription, error) {
return &response, nil
}

// GetActiveActive will retrieve an existing active-active subscription.
func (a *API) GetActiveActive(ctx context.Context, id int) (*ActiveActiveSubscription, error) {
var response ActiveActiveSubscription
err := a.client.Get(ctx, fmt.Sprintf("retrieve subscription %d", id), fmt.Sprintf("/subscriptions/%d", id), &response)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue here - "retrieve active-active subscription"

if err != nil {
return nil, wrap404Error(id, err)
}

return &response, nil
}

// Update will make changes to an existing subscription.
func (a *API) Update(ctx context.Context, id int, subscription UpdateSubscription) error {
var task internal.TaskResponse
Expand Down
Loading