-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add active-active subscription and region models, and fetch methods #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll probably want to do a nilcheck on |
||
| 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 | ||
|
|
@@ -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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
There was a problem hiding this comment.
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)