Skip to content

Commit e89399c

Browse files
author
Sam Harrison
committed
Revert "feat: add context.Context support (#197)"
This reverts commit 66288bf.
1 parent 66288bf commit e89399c

File tree

434 files changed

+3794
-12711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

434 files changed

+3794
-12711
lines changed

client/form/encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Copyright 2014 Alvaro J. Genial. All rights reserved.
44
// Use of this source code is governed by a BSD-style
55
// license that can be found in the LICENSE file.
6-
// nolint
6+
//nolint
77
package form
88

99
import (

client/form/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Copyright 2014 Alvaro J. Genial. All rights reserved.
44
// Use of this source code is governed by a BSD-style
55
// license that can be found in the LICENSE file.
6-
// nolint
6+
//nolint
77
package form
88

99
import (

client/page_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
)
99

10-
// Takes a limit on the max number of records to read and a max pageSize and calculates the max number of pages to read.
10+
//Takes a limit on the max number of records to read and a max pageSize and calculates the max number of pages to read.
1111
func ReadLimits(pageSize *int, limit *int) int {
1212
//don't care about pageSize
1313
if pageSize == nil {

rest/accounts/v1/api_service.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ import (
2020

2121
type ApiService struct {
2222
baseURL string
23-
requestHandler *twilio.RequestHandlerWithCtx
23+
requestHandler *twilio.RequestHandler
2424
}
2525

2626
func NewApiService(requestHandler *twilio.RequestHandler) *ApiService {
27-
return NewApiServiceWithCtx(twilio.UpgradeRequestHandler(requestHandler))
28-
}
29-
30-
func NewApiServiceWithCtx(requestHandler *twilio.RequestHandlerWithCtx) *ApiService {
3127
return &ApiService{
3228
requestHandler: requestHandler,
3329
baseURL: "https://accounts.twilio.com",
@@ -37,7 +33,3 @@ func NewApiServiceWithCtx(requestHandler *twilio.RequestHandlerWithCtx) *ApiServ
3733
func NewApiServiceWithClient(client twilio.BaseClient) *ApiService {
3834
return NewApiService(twilio.NewRequestHandler(client))
3935
}
40-
41-
func NewApiServiceWithClientWithCtx(client twilio.BaseClientWithCtx) *ApiService {
42-
return NewApiServiceWithCtx(twilio.NewRequestHandlerWithCtx(client))
43-
}

rest/accounts/v1/auth_tokens_promote.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,18 @@
1515
package openapi
1616

1717
import (
18-
"context"
1918
"encoding/json"
2019
"net/url"
2120
)
2221

2322
// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old primary Auth Token will result in an error.
2423
func (c *ApiService) UpdateAuthTokenPromotion() (*AccountsV1AuthTokenPromotion, error) {
25-
return c.UpdateAuthTokenPromotionWithCtx(context.TODO())
26-
}
27-
28-
// Promote the secondary Auth Token to primary. After promoting the new token, all requests to Twilio using your old primary Auth Token will result in an error.
29-
func (c *ApiService) UpdateAuthTokenPromotionWithCtx(ctx context.Context) (*AccountsV1AuthTokenPromotion, error) {
3024
path := "/v1/AuthTokens/Promote"
3125

3226
data := url.Values{}
3327
headers := make(map[string]interface{})
3428

35-
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
29+
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
3630
if err != nil {
3731
return nil, err
3832
}

rest/accounts/v1/auth_tokens_secondary.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,18 @@
1515
package openapi
1616

1717
import (
18-
"context"
1918
"encoding/json"
2019
"net/url"
2120
)
2221

2322
// Create a new secondary Auth Token
2423
func (c *ApiService) CreateSecondaryAuthToken() (*AccountsV1SecondaryAuthToken, error) {
25-
return c.CreateSecondaryAuthTokenWithCtx(context.TODO())
26-
}
27-
28-
// Create a new secondary Auth Token
29-
func (c *ApiService) CreateSecondaryAuthTokenWithCtx(ctx context.Context) (*AccountsV1SecondaryAuthToken, error) {
3024
path := "/v1/AuthTokens/Secondary"
3125

3226
data := url.Values{}
3327
headers := make(map[string]interface{})
3428

35-
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
29+
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
3630
if err != nil {
3731
return nil, err
3832
}
@@ -49,17 +43,12 @@ func (c *ApiService) CreateSecondaryAuthTokenWithCtx(ctx context.Context) (*Acco
4943

5044
// Delete the secondary Auth Token from your account
5145
func (c *ApiService) DeleteSecondaryAuthToken() error {
52-
return c.DeleteSecondaryAuthTokenWithCtx(context.TODO())
53-
}
54-
55-
// Delete the secondary Auth Token from your account
56-
func (c *ApiService) DeleteSecondaryAuthTokenWithCtx(ctx context.Context) error {
5746
path := "/v1/AuthTokens/Secondary"
5847

5948
data := url.Values{}
6049
headers := make(map[string]interface{})
6150

62-
resp, err := c.requestHandler.Delete(ctx, c.baseURL+path, data, headers)
51+
resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
6352
if err != nil {
6453
return err
6554
}

rest/accounts/v1/credentials_aws.go

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package openapi
1616

1717
import (
18-
"context"
1918
"encoding/json"
2019
"fmt"
2120
"net/url"
@@ -49,11 +48,6 @@ func (params *CreateCredentialAwsParams) SetAccountSid(AccountSid string) *Creat
4948

5049
// Create a new AWS Credential
5150
func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
52-
return c.CreateCredentialAwsWithCtx(context.TODO(), params)
53-
}
54-
55-
// Create a new AWS Credential
56-
func (c *ApiService) CreateCredentialAwsWithCtx(ctx context.Context, params *CreateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
5751
path := "/v1/Credentials/AWS"
5852

5953
data := url.Values{}
@@ -69,7 +63,7 @@ func (c *ApiService) CreateCredentialAwsWithCtx(ctx context.Context, params *Cre
6963
data.Set("AccountSid", *params.AccountSid)
7064
}
7165

72-
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
66+
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
7367
if err != nil {
7468
return nil, err
7569
}
@@ -86,18 +80,13 @@ func (c *ApiService) CreateCredentialAwsWithCtx(ctx context.Context, params *Cre
8680

8781
// Delete a Credential from your account
8882
func (c *ApiService) DeleteCredentialAws(Sid string) error {
89-
return c.DeleteCredentialAwsWithCtx(context.TODO(), Sid)
90-
}
91-
92-
// Delete a Credential from your account
93-
func (c *ApiService) DeleteCredentialAwsWithCtx(ctx context.Context, Sid string) error {
9483
path := "/v1/Credentials/AWS/{Sid}"
9584
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
9685

9786
data := url.Values{}
9887
headers := make(map[string]interface{})
9988

100-
resp, err := c.requestHandler.Delete(ctx, c.baseURL+path, data, headers)
89+
resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
10190
if err != nil {
10291
return err
10392
}
@@ -109,18 +98,13 @@ func (c *ApiService) DeleteCredentialAwsWithCtx(ctx context.Context, Sid string)
10998

11099
// Fetch the AWS credentials specified by the provided Credential Sid
111100
func (c *ApiService) FetchCredentialAws(Sid string) (*AccountsV1CredentialAws, error) {
112-
return c.FetchCredentialAwsWithCtx(context.TODO(), Sid)
113-
}
114-
115-
// Fetch the AWS credentials specified by the provided Credential Sid
116-
func (c *ApiService) FetchCredentialAwsWithCtx(ctx context.Context, Sid string) (*AccountsV1CredentialAws, error) {
117101
path := "/v1/Credentials/AWS/{Sid}"
118102
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
119103

120104
data := url.Values{}
121105
headers := make(map[string]interface{})
122106

123-
resp, err := c.requestHandler.Get(ctx, c.baseURL+path, data, headers)
107+
resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
124108
if err != nil {
125109
return nil, err
126110
}
@@ -154,11 +138,6 @@ func (params *ListCredentialAwsParams) SetLimit(Limit int) *ListCredentialAwsPar
154138

155139
// Retrieve a single page of CredentialAws records from the API. Request is executed immediately.
156140
func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToken, pageNumber string) (*ListCredentialAwsResponse, error) {
157-
return c.PageCredentialAwsWithCtx(context.TODO(), params, pageToken, pageNumber)
158-
}
159-
160-
// Retrieve a single page of CredentialAws records from the API. Request is executed immediately.
161-
func (c *ApiService) PageCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams, pageToken, pageNumber string) (*ListCredentialAwsResponse, error) {
162141
path := "/v1/Credentials/AWS"
163142

164143
data := url.Values{}
@@ -175,7 +154,7 @@ func (c *ApiService) PageCredentialAwsWithCtx(ctx context.Context, params *ListC
175154
data.Set("Page", pageNumber)
176155
}
177156

178-
resp, err := c.requestHandler.Get(ctx, c.baseURL+path, data, headers)
157+
resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
179158
if err != nil {
180159
return nil, err
181160
}
@@ -192,12 +171,7 @@ func (c *ApiService) PageCredentialAwsWithCtx(ctx context.Context, params *ListC
192171

193172
// Lists CredentialAws records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
194173
func (c *ApiService) ListCredentialAws(params *ListCredentialAwsParams) ([]AccountsV1CredentialAws, error) {
195-
return c.ListCredentialAwsWithCtx(context.TODO(), params)
196-
}
197-
198-
// Lists CredentialAws records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
199-
func (c *ApiService) ListCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams) ([]AccountsV1CredentialAws, error) {
200-
response, errors := c.StreamCredentialAwsWithCtx(ctx, params)
174+
response, errors := c.StreamCredentialAws(params)
201175

202176
records := make([]AccountsV1CredentialAws, 0)
203177
for record := range response {
@@ -213,11 +187,6 @@ func (c *ApiService) ListCredentialAwsWithCtx(ctx context.Context, params *ListC
213187

214188
// Streams CredentialAws records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
215189
func (c *ApiService) StreamCredentialAws(params *ListCredentialAwsParams) (chan AccountsV1CredentialAws, chan error) {
216-
return c.StreamCredentialAwsWithCtx(context.TODO(), params)
217-
}
218-
219-
// Streams CredentialAws records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
220-
func (c *ApiService) StreamCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams) (chan AccountsV1CredentialAws, chan error) {
221190
if params == nil {
222191
params = &ListCredentialAwsParams{}
223192
}
@@ -226,19 +195,19 @@ func (c *ApiService) StreamCredentialAwsWithCtx(ctx context.Context, params *Lis
226195
recordChannel := make(chan AccountsV1CredentialAws, 1)
227196
errorChannel := make(chan error, 1)
228197

229-
response, err := c.PageCredentialAwsWithCtx(ctx, params, "", "")
198+
response, err := c.PageCredentialAws(params, "", "")
230199
if err != nil {
231200
errorChannel <- err
232201
close(recordChannel)
233202
close(errorChannel)
234203
} else {
235-
go c.streamCredentialAws(ctx, response, params, recordChannel, errorChannel)
204+
go c.streamCredentialAws(response, params, recordChannel, errorChannel)
236205
}
237206

238207
return recordChannel, errorChannel
239208
}
240209

241-
func (c *ApiService) streamCredentialAws(ctx context.Context, response *ListCredentialAwsResponse, params *ListCredentialAwsParams, recordChannel chan AccountsV1CredentialAws, errorChannel chan error) {
210+
func (c *ApiService) streamCredentialAws(response *ListCredentialAwsResponse, params *ListCredentialAwsParams, recordChannel chan AccountsV1CredentialAws, errorChannel chan error) {
242211
curRecord := 1
243212

244213
for response != nil {
@@ -253,7 +222,7 @@ func (c *ApiService) streamCredentialAws(ctx context.Context, response *ListCred
253222
}
254223
}
255224

256-
record, err := client.GetNextWithCtx(ctx, c.baseURL, response, c.getNextListCredentialAwsResponse)
225+
record, err := client.GetNext(c.baseURL, response, c.getNextListCredentialAwsResponse)
257226
if err != nil {
258227
errorChannel <- err
259228
break
@@ -268,11 +237,11 @@ func (c *ApiService) streamCredentialAws(ctx context.Context, response *ListCred
268237
close(errorChannel)
269238
}
270239

271-
func (c *ApiService) getNextListCredentialAwsResponse(ctx context.Context, nextPageUrl string) (interface{}, error) {
240+
func (c *ApiService) getNextListCredentialAwsResponse(nextPageUrl string) (interface{}, error) {
272241
if nextPageUrl == "" {
273242
return nil, nil
274243
}
275-
resp, err := c.requestHandler.Get(ctx, nextPageUrl, nil, nil)
244+
resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
276245
if err != nil {
277246
return nil, err
278247
}
@@ -299,11 +268,6 @@ func (params *UpdateCredentialAwsParams) SetFriendlyName(FriendlyName string) *U
299268

300269
// Modify the properties of a given Account
301270
func (c *ApiService) UpdateCredentialAws(Sid string, params *UpdateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
302-
return c.UpdateCredentialAwsWithCtx(context.TODO(), Sid, params)
303-
}
304-
305-
// Modify the properties of a given Account
306-
func (c *ApiService) UpdateCredentialAwsWithCtx(ctx context.Context, Sid string, params *UpdateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
307271
path := "/v1/Credentials/AWS/{Sid}"
308272
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
309273

@@ -314,7 +278,7 @@ func (c *ApiService) UpdateCredentialAwsWithCtx(ctx context.Context, Sid string,
314278
data.Set("FriendlyName", *params.FriendlyName)
315279
}
316280

317-
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
281+
resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
318282
if err != nil {
319283
return nil, err
320284
}

0 commit comments

Comments
 (0)