Skip to content

Commit

Permalink
regenerate SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
natebrennand committed Oct 30, 2022
1 parent 1de5352 commit c7a69c3
Show file tree
Hide file tree
Showing 428 changed files with 13,051 additions and 3,330 deletions.
5 changes: 3 additions & 2 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
package twilio

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
Api "github.com/twilio/twilio-go/rest/api/v2010"
ChatV2 "github.com/twilio/twilio-go/rest/chat/v2"
EventsV1 "github.com/twilio/twilio-go/rest/events/v1"
"os"
"testing"
)

var from string
Expand Down
10 changes: 9 additions & 1 deletion rest/accounts/v1/api_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import (

type ApiService struct {
baseURL string
requestHandler *twilio.RequestHandler
requestHandler *twilio.RequestHandlerWithCtx
}

func NewApiService(requestHandler *twilio.RequestHandler) *ApiService {
return NewApiServiceWithCtx(twilio.UpgradeRequestHandler(requestHandler))
}

func NewApiServiceWithCtx(requestHandler *twilio.RequestHandlerWithCtx) *ApiService {
return &ApiService{
requestHandler: requestHandler,
baseURL: "https://accounts.twilio.com",
Expand All @@ -33,3 +37,7 @@ func NewApiService(requestHandler *twilio.RequestHandler) *ApiService {
func NewApiServiceWithClient(client twilio.BaseClient) *ApiService {
return NewApiService(twilio.NewRequestHandler(client))
}

func NewApiServiceWithClientWithCtx(client twilio.BaseClientWithCtx) *ApiService {
return NewApiServiceWithCtx(twilio.NewRequestHandlerWithCtx(client))
}
8 changes: 7 additions & 1 deletion rest/accounts/v1/auth_tokens_promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
package openapi

import (
"context"
"encoding/json"
"net/url"
)

// 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.
func (c *ApiService) UpdateAuthTokenPromotion() (*AccountsV1AuthTokenPromotion, error) {
return c.UpdateAuthTokenPromotionWithCtx(context.TODO())
}

// 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.
func (c *ApiService) UpdateAuthTokenPromotionWithCtx(ctx context.Context) (*AccountsV1AuthTokenPromotion, error) {
path := "/v1/AuthTokens/Promote"

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

resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
Expand Down
15 changes: 13 additions & 2 deletions rest/accounts/v1/auth_tokens_secondary.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
package openapi

import (
"context"
"encoding/json"
"net/url"
)

// Create a new secondary Auth Token
func (c *ApiService) CreateSecondaryAuthToken() (*AccountsV1SecondaryAuthToken, error) {
return c.CreateSecondaryAuthTokenWithCtx(context.TODO())
}

// Create a new secondary Auth Token
func (c *ApiService) CreateSecondaryAuthTokenWithCtx(ctx context.Context) (*AccountsV1SecondaryAuthToken, error) {
path := "/v1/AuthTokens/Secondary"

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

resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
Expand All @@ -43,12 +49,17 @@ func (c *ApiService) CreateSecondaryAuthToken() (*AccountsV1SecondaryAuthToken,

// Delete the secondary Auth Token from your account
func (c *ApiService) DeleteSecondaryAuthToken() error {
return c.DeleteSecondaryAuthTokenWithCtx(context.TODO())
}

// Delete the secondary Auth Token from your account
func (c *ApiService) DeleteSecondaryAuthTokenWithCtx(ctx context.Context) error {
path := "/v1/AuthTokens/Secondary"

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

resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Delete(ctx, c.baseURL+path, data, headers)
if err != nil {
return err
}
Expand Down
60 changes: 48 additions & 12 deletions rest/accounts/v1/credentials_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package openapi

import (
"context"
"encoding/json"
"fmt"
"net/url"
Expand Down Expand Up @@ -48,6 +49,11 @@ func (params *CreateCredentialAwsParams) SetAccountSid(AccountSid string) *Creat

// Create a new AWS Credential
func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
return c.CreateCredentialAwsWithCtx(context.TODO(), params)
}

// Create a new AWS Credential
func (c *ApiService) CreateCredentialAwsWithCtx(ctx context.Context, params *CreateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
path := "/v1/Credentials/AWS"

data := url.Values{}
Expand All @@ -63,7 +69,7 @@ func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*Ac
data.Set("AccountSid", *params.AccountSid)
}

resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
Expand All @@ -80,13 +86,18 @@ func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*Ac

// Delete a Credential from your account
func (c *ApiService) DeleteCredentialAws(Sid string) error {
return c.DeleteCredentialAwsWithCtx(context.TODO(), Sid)
}

// Delete a Credential from your account
func (c *ApiService) DeleteCredentialAwsWithCtx(ctx context.Context, Sid string) error {
path := "/v1/Credentials/AWS/{Sid}"
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)

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

resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Delete(ctx, c.baseURL+path, data, headers)
if err != nil {
return err
}
Expand All @@ -98,13 +109,18 @@ func (c *ApiService) DeleteCredentialAws(Sid string) error {

// Fetch the AWS credentials specified by the provided Credential Sid
func (c *ApiService) FetchCredentialAws(Sid string) (*AccountsV1CredentialAws, error) {
return c.FetchCredentialAwsWithCtx(context.TODO(), Sid)
}

// Fetch the AWS credentials specified by the provided Credential Sid
func (c *ApiService) FetchCredentialAwsWithCtx(ctx context.Context, Sid string) (*AccountsV1CredentialAws, error) {
path := "/v1/Credentials/AWS/{Sid}"
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)

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

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

// Retrieve a single page of CredentialAws records from the API. Request is executed immediately.
func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToken, pageNumber string) (*ListCredentialAwsResponse, error) {
return c.PageCredentialAwsWithCtx(context.TODO(), params, pageToken, pageNumber)
}

// Retrieve a single page of CredentialAws records from the API. Request is executed immediately.
func (c *ApiService) PageCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams, pageToken, pageNumber string) (*ListCredentialAwsResponse, error) {
path := "/v1/Credentials/AWS"

data := url.Values{}
Expand All @@ -154,7 +175,7 @@ func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToke
data.Set("Page", pageNumber)
}

resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Get(ctx, c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
Expand All @@ -171,7 +192,12 @@ func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToke

// Lists CredentialAws records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
func (c *ApiService) ListCredentialAws(params *ListCredentialAwsParams) ([]AccountsV1CredentialAws, error) {
response, errors := c.StreamCredentialAws(params)
return c.ListCredentialAwsWithCtx(context.TODO(), params)
}

// Lists CredentialAws records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
func (c *ApiService) ListCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams) ([]AccountsV1CredentialAws, error) {
response, errors := c.StreamCredentialAwsWithCtx(ctx, params)

records := make([]AccountsV1CredentialAws, 0)
for record := range response {
Expand All @@ -187,6 +213,11 @@ func (c *ApiService) ListCredentialAws(params *ListCredentialAwsParams) ([]Accou

// Streams CredentialAws records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
func (c *ApiService) StreamCredentialAws(params *ListCredentialAwsParams) (chan AccountsV1CredentialAws, chan error) {
return c.StreamCredentialAwsWithCtx(context.TODO(), params)
}

// Streams CredentialAws records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
func (c *ApiService) StreamCredentialAwsWithCtx(ctx context.Context, params *ListCredentialAwsParams) (chan AccountsV1CredentialAws, chan error) {
if params == nil {
params = &ListCredentialAwsParams{}
}
Expand All @@ -195,19 +226,19 @@ func (c *ApiService) StreamCredentialAws(params *ListCredentialAwsParams) (chan
recordChannel := make(chan AccountsV1CredentialAws, 1)
errorChannel := make(chan error, 1)

response, err := c.PageCredentialAws(params, "", "")
response, err := c.PageCredentialAwsWithCtx(ctx, params, "", "")
if err != nil {
errorChannel <- err
close(recordChannel)
close(errorChannel)
} else {
go c.streamCredentialAws(response, params, recordChannel, errorChannel)
go c.streamCredentialAws(ctx, response, params, recordChannel, errorChannel)
}

return recordChannel, errorChannel
}

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

for response != nil {
Expand All @@ -222,7 +253,7 @@ func (c *ApiService) streamCredentialAws(response *ListCredentialAwsResponse, pa
}
}

record, err := client.GetNext(c.baseURL, response, c.getNextListCredentialAwsResponse)
record, err := client.GetNextWithCtx(ctx, c.baseURL, response, c.getNextListCredentialAwsResponse)
if err != nil {
errorChannel <- err
break
Expand All @@ -237,11 +268,11 @@ func (c *ApiService) streamCredentialAws(response *ListCredentialAwsResponse, pa
close(errorChannel)
}

func (c *ApiService) getNextListCredentialAwsResponse(nextPageUrl string) (interface{}, error) {
func (c *ApiService) getNextListCredentialAwsResponse(ctx context.Context, nextPageUrl string) (interface{}, error) {
if nextPageUrl == "" {
return nil, nil
}
resp, err := c.requestHandler.Get(nextPageUrl, nil, nil)
resp, err := c.requestHandler.Get(ctx, nextPageUrl, nil, nil)
if err != nil {
return nil, err
}
Expand All @@ -268,6 +299,11 @@ func (params *UpdateCredentialAwsParams) SetFriendlyName(FriendlyName string) *U

// Modify the properties of a given Account
func (c *ApiService) UpdateCredentialAws(Sid string, params *UpdateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
return c.UpdateCredentialAwsWithCtx(context.TODO(), Sid, params)
}

// Modify the properties of a given Account
func (c *ApiService) UpdateCredentialAwsWithCtx(ctx context.Context, Sid string, params *UpdateCredentialAwsParams) (*AccountsV1CredentialAws, error) {
path := "/v1/Credentials/AWS/{Sid}"
path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)

Expand All @@ -278,7 +314,7 @@ func (c *ApiService) UpdateCredentialAws(Sid string, params *UpdateCredentialAws
data.Set("FriendlyName", *params.FriendlyName)
}

resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
resp, err := c.requestHandler.Post(ctx, c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit c7a69c3

Please sign in to comment.