1515package openapi
1616
1717import (
18+ "context"
1819 "encoding/json"
1920 "fmt"
2021 "net/url"
@@ -48,6 +49,11 @@ func (params *CreateCredentialAwsParams) SetAccountSid(AccountSid string) *Creat
4849
4950// Create a new AWS Credential
5051func (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 ) {
5157 path := "/v1/Credentials/AWS"
5258
5359 data := url.Values {}
@@ -63,7 +69,7 @@ func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*Ac
6369 data .Set ("AccountSid" , * params .AccountSid )
6470 }
6571
66- resp , err := c .requestHandler .Post (c .baseURL + path , data , headers )
72+ resp , err := c .requestHandler .Post (ctx , c .baseURL + path , data , headers )
6773 if err != nil {
6874 return nil , err
6975 }
@@ -80,13 +86,18 @@ func (c *ApiService) CreateCredentialAws(params *CreateCredentialAwsParams) (*Ac
8086
8187// Delete a Credential from your account
8288func (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 {
8394 path := "/v1/Credentials/AWS/{Sid}"
8495 path = strings .Replace (path , "{" + "Sid" + "}" , Sid , - 1 )
8596
8697 data := url.Values {}
8798 headers := make (map [string ]interface {})
8899
89- resp , err := c .requestHandler .Delete (c .baseURL + path , data , headers )
100+ resp , err := c .requestHandler .Delete (ctx , c .baseURL + path , data , headers )
90101 if err != nil {
91102 return err
92103 }
@@ -98,13 +109,18 @@ func (c *ApiService) DeleteCredentialAws(Sid string) error {
98109
99110// Fetch the AWS credentials specified by the provided Credential Sid
100111func (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 ) {
101117 path := "/v1/Credentials/AWS/{Sid}"
102118 path = strings .Replace (path , "{" + "Sid" + "}" , Sid , - 1 )
103119
104120 data := url.Values {}
105121 headers := make (map [string ]interface {})
106122
107- resp , err := c .requestHandler .Get (c .baseURL + path , data , headers )
123+ resp , err := c .requestHandler .Get (ctx , c .baseURL + path , data , headers )
108124 if err != nil {
109125 return nil , err
110126 }
@@ -138,6 +154,11 @@ func (params *ListCredentialAwsParams) SetLimit(Limit int) *ListCredentialAwsPar
138154
139155// Retrieve a single page of CredentialAws records from the API. Request is executed immediately.
140156func (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 ) {
141162 path := "/v1/Credentials/AWS"
142163
143164 data := url.Values {}
@@ -154,7 +175,7 @@ func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToke
154175 data .Set ("Page" , pageNumber )
155176 }
156177
157- resp , err := c .requestHandler .Get (c .baseURL + path , data , headers )
178+ resp , err := c .requestHandler .Get (ctx , c .baseURL + path , data , headers )
158179 if err != nil {
159180 return nil , err
160181 }
@@ -171,7 +192,12 @@ func (c *ApiService) PageCredentialAws(params *ListCredentialAwsParams, pageToke
171192
172193// Lists CredentialAws records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning.
173194func (c * ApiService ) ListCredentialAws (params * ListCredentialAwsParams ) ([]AccountsV1CredentialAws , error ) {
174- response , errors := c .StreamCredentialAws (params )
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 )
175201
176202 records := make ([]AccountsV1CredentialAws , 0 )
177203 for record := range response {
@@ -187,6 +213,11 @@ func (c *ApiService) ListCredentialAws(params *ListCredentialAwsParams) ([]Accou
187213
188214// Streams CredentialAws records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
189215func (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 ) {
190221 if params == nil {
191222 params = & ListCredentialAwsParams {}
192223 }
@@ -195,19 +226,19 @@ func (c *ApiService) StreamCredentialAws(params *ListCredentialAwsParams) (chan
195226 recordChannel := make (chan AccountsV1CredentialAws , 1 )
196227 errorChannel := make (chan error , 1 )
197228
198- response , err := c .PageCredentialAws ( params , "" , "" )
229+ response , err := c .PageCredentialAwsWithCtx ( ctx , params , "" , "" )
199230 if err != nil {
200231 errorChannel <- err
201232 close (recordChannel )
202233 close (errorChannel )
203234 } else {
204- go c .streamCredentialAws (response , params , recordChannel , errorChannel )
235+ go c .streamCredentialAws (ctx , response , params , recordChannel , errorChannel )
205236 }
206237
207238 return recordChannel , errorChannel
208239}
209240
210- func (c * ApiService ) streamCredentialAws (response * ListCredentialAwsResponse , params * ListCredentialAwsParams , recordChannel chan AccountsV1CredentialAws , errorChannel chan error ) {
241+ func (c * ApiService ) streamCredentialAws (ctx context. Context , response * ListCredentialAwsResponse , params * ListCredentialAwsParams , recordChannel chan AccountsV1CredentialAws , errorChannel chan error ) {
211242 curRecord := 1
212243
213244 for response != nil {
@@ -222,7 +253,7 @@ func (c *ApiService) streamCredentialAws(response *ListCredentialAwsResponse, pa
222253 }
223254 }
224255
225- record , err := client .GetNext ( c .baseURL , response , c .getNextListCredentialAwsResponse )
256+ record , err := client .GetNextWithCtx ( ctx , c .baseURL , response , c .getNextListCredentialAwsResponse )
226257 if err != nil {
227258 errorChannel <- err
228259 break
@@ -237,11 +268,11 @@ func (c *ApiService) streamCredentialAws(response *ListCredentialAwsResponse, pa
237268 close (errorChannel )
238269}
239270
240- func (c * ApiService ) getNextListCredentialAwsResponse (nextPageUrl string ) (interface {}, error ) {
271+ func (c * ApiService ) getNextListCredentialAwsResponse (ctx context. Context , nextPageUrl string ) (interface {}, error ) {
241272 if nextPageUrl == "" {
242273 return nil , nil
243274 }
244- resp , err := c .requestHandler .Get (nextPageUrl , nil , nil )
275+ resp , err := c .requestHandler .Get (ctx , nextPageUrl , nil , nil )
245276 if err != nil {
246277 return nil , err
247278 }
@@ -268,6 +299,11 @@ func (params *UpdateCredentialAwsParams) SetFriendlyName(FriendlyName string) *U
268299
269300// Modify the properties of a given Account
270301func (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 ) {
271307 path := "/v1/Credentials/AWS/{Sid}"
272308 path = strings .Replace (path , "{" + "Sid" + "}" , Sid , - 1 )
273309
@@ -278,7 +314,7 @@ func (c *ApiService) UpdateCredentialAws(Sid string, params *UpdateCredentialAws
278314 data .Set ("FriendlyName" , * params .FriendlyName )
279315 }
280316
281- resp , err := c .requestHandler .Post (c .baseURL + path , data , headers )
317+ resp , err := c .requestHandler .Post (ctx , c .baseURL + path , data , headers )
282318 if err != nil {
283319 return nil , err
284320 }
0 commit comments