Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit cd10b15

Browse files
committed
Don't paginate autoscale webhook create results
1 parent 43086e9 commit cd10b15

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

rackspace/autoscale/v1/webhooks/requests.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@ func Create(client *gophercloud.ServiceClient, groupID, policyID string, opts Cr
7878
return res
7979
}
8080

81-
resp, err := client.Post(createURL(client, groupID, policyID), reqBody, &res.Body, nil)
81+
_, res.Err = client.Post(createURL(client, groupID, policyID), reqBody, &res.Body, nil)
8282

83-
if err != nil {
84-
res.Err = err
85-
return res
86-
}
87-
88-
pr := pagination.PageResultFromParsed(resp, res.Body)
89-
return CreateResult{pagination.SinglePageBase(pr)}
83+
return res
9084
}
9185

9286
// Get requests the details of a single webhook with the given ID.

rackspace/autoscale/v1/webhooks/requests_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestCreate(t *testing.T) {
6767
},
6868
}
6969

70-
webhooks, err := Create(client, groupID, policyID, opts).ExtractWebhooks()
70+
webhooks, err := Create(client, groupID, policyID, opts).Extract()
7171

7272
th.AssertNoErr(t, err)
7373
th.CheckDeepEquals(t, FirstWebhook, webhooks[0])

rackspace/autoscale/v1/webhooks/results.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@ func (r webhookResult) Extract() (*Webhook, error) {
2626
return &response.Webhook, err
2727
}
2828

29-
// CreateResult represents the result of a create operation. Multiple webhooks
30-
// can be created in a single call, so the result should be treated as a typical
31-
// pagination Page. ExtractWebhooks() can be used to extract a slice of
32-
// Webhooks from a single page.
29+
// CreateResult represents the result of a create operation.
3330
type CreateResult struct {
34-
pagination.SinglePageBase
31+
webhookResult
3532
}
3633

37-
// ExtractWebhooks extracts a slice of Webhooks from a CreateResult.
38-
func (res CreateResult) ExtractWebhooks() ([]Webhook, error) {
34+
// Extract extracts a slice of Webhooks from a CreateResult. Multiple webhooks
35+
// can be created in a single operation, so the result of a create is always a
36+
// list of webhooks.
37+
func (res CreateResult) Extract() ([]Webhook, error) {
3938
if res.Err != nil {
4039
return nil, res.Err
4140
}

0 commit comments

Comments
 (0)