Skip to content

Commit 5a3c480

Browse files
committed
Added passthrough cancellationTokens
1 parent 982b2e1 commit 5a3c480

File tree

507 files changed

+2946
-2904
lines changed

Some content is hidden

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

507 files changed

+2946
-2904
lines changed

src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public bool isTokenExpired(string token){
236236
///
237237
/// <param name="request">request to make</param>
238238
/// <returns>Task that resolves to the response of the request</returns>
239-
public async Task<Response> RequestAsync(TokenRequest request, CancellationToken cancellationToken = default)
239+
public async Task<Response> RequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
240240
{
241241
request.SetAuth(_accessToken);
242242

src/Twilio/Clients/ITwilioRestClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface ITwilioRestClient
3737
///
3838
/// <param name="request">Request to make</param>
3939
/// <returns>response of the request</returns>
40-
System.Threading.Tasks.Task<Response> RequestAsync(Request request, CancellationToken cancellationToken = default);
40+
System.Threading.Tasks.Task<Response> RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
4141
#endif
4242
}
4343
}

src/Twilio/Clients/TwilioRestClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public Response Request(Request request)
169169
///
170170
/// <param name="request">request to make</param>
171171
/// <returns>Task that resolves to the response of the request</returns>
172-
public async Task<Response> RequestAsync(Request request, CancellationToken cancellationToken = default)
172+
public async Task<Response> RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
173173
{
174174
if(_username != null && _password != null){
175175
request.SetAuth(_username, _password);

src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public override Response MakeRequest(TokenRequest request)
6060
/// </summary>
6161
/// <param name="request">Twilio response</param>
6262
/// <returns>Task that resolves to the response</returns>
63-
public override async Task<Response> MakeRequestAsync(TokenRequest request, CancellationToken cancellationToken = default)
63+
public override async Task<Response> MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
6464
{
6565
var httpRequest = BuildHttpRequest(request);
6666
if (!Equals(request.Method, HttpMethod.Get))
@@ -87,7 +87,7 @@ public override async Task<Response> MakeRequestAsync(TokenRequest request, Canc
8787
// Create and return a new Response. Keep a reference to the last
8888
// response for debugging, but don't return it as it may be shared
8989
// among threads.
90-
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false), httpResponse.Headers);
90+
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers);
9191
this.LastResponse = response;
9292
return response;
9393
}

src/Twilio/Http/BearerToken/TokenHttpClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public abstract class TokenHttpClient
3636
/// <param name="request">request to make</param>
3737
/// <exception>throws exception on network or connection errors.</exception>
3838
/// <returns>response of the request</returns>
39-
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(TokenRequest request, CancellationToken cancellationToken = Default);
39+
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default);
4040
#endif
4141

4242
}

src/Twilio/Http/HttpClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class HttpClient
3434
/// <param name="request">request to make</param>
3535
/// <exception>throws exception on network or connection errors.</exception>
3636
/// <returns>response of the request</returns>
37-
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(Request request, CancellationToken cancellationToken = default);
37+
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
3838
#endif
3939

4040
/// <summary>

src/Twilio/Http/SystemNetHttpClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public override Response MakeRequest(Request request)
5858
/// </summary>
5959
/// <param name="request">Twilio response</param>
6060
/// <returns>Task that resolves to the response</returns>
61-
public override async Task<Response> MakeRequestAsync(Request request, CancellationToken cancellationToken = default)
61+
public override async Task<Response> MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
6262
{
6363
var httpRequest = BuildHttpRequest(request);
6464
if (!Equals(request.Method, HttpMethod.Get))
@@ -82,7 +82,7 @@ public override async Task<Response> MakeRequestAsync(Request request, Cancellat
8282
// Create and return a new Response. Keep a reference to the last
8383
// response for debugging, but don't return it as it may be shared
8484
// among threads.
85-
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false), httpResponse.Headers);
85+
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers);
8686
this.LastResponse = response;
8787
return response;
8888
}

src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static AuthTokenPromotionResource Update(UpdateAuthTokenPromotionOptions
6868
#if !NET35
6969
public static async System.Threading.Tasks.Task<AuthTokenPromotionResource> UpdateAsync(UpdateAuthTokenPromotionOptions options,
7070
ITwilioRestClient client = null,
71-
CancellationToken cancellationToken = default)
71+
System.Threading.CancellationToken cancellationToken = default)
7272
{
7373
client = client ?? TwilioClient.GetRestClient();
7474
var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
@@ -92,7 +92,7 @@ public static AuthTokenPromotionResource Update(
9292
/// <returns> Task that resolves to A single instance of AuthTokenPromotion </returns>
9393
public static async System.Threading.Tasks.Task<AuthTokenPromotionResource> UpdateAsync(
9494
ITwilioRestClient client = null,
95-
CancellationToken cancellationToken = default)
95+
System.Threading.CancellationToken cancellationToken = default)
9696
{
9797
var options = new UpdateAuthTokenPromotionOptions(){ };
9898
return await UpdateAsync(options, client, cancellationToken);

src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static BulkConsentsResource Create(CreateBulkConsentsOptions options, ITw
6666
/// <param name="options"> Create BulkConsents parameters </param>
6767
/// <param name="client"> Client to make requests to Twilio </param>
6868
/// <returns> Task that resolves to A single instance of BulkConsents </returns>
69-
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
69+
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
7070
{
7171
client = client ?? TwilioClient.GetRestClient();
7272
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
@@ -93,7 +93,8 @@ public static BulkConsentsResource Create(
9393
/// <returns> Task that resolves to A single instance of BulkConsents </returns>
9494
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(
9595
List<object> items,
96-
ITwilioRestClient client = null)
96+
ITwilioRestClient client = null,
97+
System.Threading.CancellationToken cancellationToken = default)
9798
{
9899
var options = new CreateBulkConsentsOptions(items){ };
99100
return await CreateAsync(options, client, cancellationToken);

src/Twilio/Rest/Accounts/V1/BulkContactsResource.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static BulkContactsResource Create(CreateBulkContactsOptions options, ITw
6666
/// <param name="options"> Create BulkContacts parameters </param>
6767
/// <param name="client"> Client to make requests to Twilio </param>
6868
/// <returns> Task that resolves to A single instance of BulkContacts </returns>
69-
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(CreateBulkContactsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
69+
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(CreateBulkContactsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
7070
{
7171
client = client ?? TwilioClient.GetRestClient();
7272
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
@@ -93,7 +93,8 @@ public static BulkContactsResource Create(
9393
/// <returns> Task that resolves to A single instance of BulkContacts </returns>
9494
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(
9595
List<object> items,
96-
ITwilioRestClient client = null)
96+
ITwilioRestClient client = null,
97+
System.Threading.CancellationToken cancellationToken = default)
9798
{
9899
var options = new CreateBulkContactsOptions(items){ };
99100
return await CreateAsync(options, client, cancellationToken);

src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs

+13-10
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient cli
6666
/// <param name="options"> Create Aws parameters </param>
6767
/// <param name="client"> Client to make requests to Twilio </param>
6868
/// <returns> Task that resolves to A single instance of Aws </returns>
69-
public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
69+
public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
7070
{
7171
client = client ?? TwilioClient.GetRestClient();
7272
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
@@ -101,7 +101,8 @@ public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(
101101
string credentials,
102102
string friendlyName = null,
103103
string accountSid = null,
104-
ITwilioRestClient client = null)
104+
ITwilioRestClient client = null,
105+
System.Threading.CancellationToken cancellationToken = default)
105106
{
106107
var options = new CreateAwsOptions(credentials){ FriendlyName = friendlyName, AccountSid = accountSid };
107108
return await CreateAsync(options, client, cancellationToken);
@@ -147,7 +148,7 @@ public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = n
147148
/// <returns> Task that resolves to A single instance of Aws </returns>
148149
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteAwsOptions options,
149150
ITwilioRestClient client = null,
150-
CancellationToken cancellationToken = default)
151+
System.Threading.CancellationToken cancellationToken = default)
151152
{
152153
client = client ?? TwilioClient.GetRestClient();
153154
var response = await client.RequestAsync(BuildDeleteRequest(options, client), cancellationToken);
@@ -170,7 +171,7 @@ public static bool Delete(string pathSid, ITwilioRestClient client = null)
170171
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the AWS resource to delete. </param>
171172
/// <param name="client"> Client to make requests to Twilio </param>
172173
/// <returns> Task that resolves to A single instance of Aws </returns>
173-
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
174+
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
174175
{
175176
var options = new DeleteAwsOptions(pathSid) ;
176177
return await DeleteAsync(options, client, cancellationToken);
@@ -210,7 +211,7 @@ public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient clien
210211
/// <param name="options"> Fetch Aws parameters </param>
211212
/// <param name="client"> Client to make requests to Twilio </param>
212213
/// <returns> Task that resolves to A single instance of Aws </returns>
213-
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
214+
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
214215
{
215216
client = client ?? TwilioClient.GetRestClient();
216217
var response = await client.RequestAsync(BuildFetchRequest(options, client), cancellationToken);
@@ -234,7 +235,7 @@ public static AwsResource Fetch(
234235
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the AWS resource to fetch. </param>
235236
/// <param name="client"> Client to make requests to Twilio </param>
236237
/// <returns> Task that resolves to A single instance of Aws </returns>
237-
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
238+
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(string pathSid, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
238239
{
239240
var options = new FetchAwsOptions(pathSid){ };
240241
return await FetchAsync(options, client, cancellationToken);
@@ -272,7 +273,7 @@ public static ResourceSet<AwsResource> Read(ReadAwsOptions options, ITwilioRestC
272273
/// <param name="options"> Read Aws parameters </param>
273274
/// <param name="client"> Client to make requests to Twilio </param>
274275
/// <returns> Task that resolves to A single instance of Aws </returns>
275-
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
276+
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
276277
{
277278
client = client ?? TwilioClient.GetRestClient();
278279
var response = await client.RequestAsync(BuildReadRequest(options, client), cancellationToken);
@@ -304,7 +305,8 @@ public static ResourceSet<AwsResource> Read(
304305
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(
305306
int? pageSize = null,
306307
long? limit = null,
307-
ITwilioRestClient client = null)
308+
ITwilioRestClient client = null,
309+
System.Threading.CancellationToken cancellationToken = default)
308310
{
309311
var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit};
310312
return await ReadAsync(options, client, cancellationToken);
@@ -396,7 +398,7 @@ public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient cli
396398
#if !NET35
397399
public static async System.Threading.Tasks.Task<AwsResource> UpdateAsync(UpdateAwsOptions options,
398400
ITwilioRestClient client = null,
399-
CancellationToken cancellationToken = default)
401+
System.Threading.CancellationToken cancellationToken = default)
400402
{
401403
client = client ?? TwilioClient.GetRestClient();
402404
var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
@@ -427,7 +429,8 @@ public static AwsResource Update(
427429
public static async System.Threading.Tasks.Task<AwsResource> UpdateAsync(
428430
string pathSid,
429431
string friendlyName = null,
430-
ITwilioRestClient client = null)
432+
ITwilioRestClient client = null,
433+
System.Threading.CancellationToken cancellationToken = default)
431434
{
432435
var options = new UpdateAwsOptions(pathSid){ FriendlyName = friendlyName };
433436
return await UpdateAsync(options, client, cancellationToken);

0 commit comments

Comments
 (0)