Skip to content

Commit

Permalink
Added passthrough cancellationTokens
Browse files Browse the repository at this point in the history
  • Loading branch information
joewashear007 committed Jan 13, 2025
1 parent 982b2e1 commit 5a3c480
Show file tree
Hide file tree
Showing 507 changed files with 2,946 additions and 2,904 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public bool isTokenExpired(string token){
///
/// <param name="request">request to make</param>
/// <returns>Task that resolves to the response of the request</returns>
public async Task<Response> RequestAsync(TokenRequest request, CancellationToken cancellationToken = default)
public async Task<Response> RequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
{
request.SetAuth(_accessToken);

Expand Down
2 changes: 1 addition & 1 deletion src/Twilio/Clients/ITwilioRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface ITwilioRestClient
///
/// <param name="request">Request to make</param>
/// <returns>response of the request</returns>
System.Threading.Tasks.Task<Response> RequestAsync(Request request, CancellationToken cancellationToken = default);
System.Threading.Tasks.Task<Response> RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Twilio/Clients/TwilioRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Response Request(Request request)
///
/// <param name="request">request to make</param>
/// <returns>Task that resolves to the response of the request</returns>
public async Task<Response> RequestAsync(Request request, CancellationToken cancellationToken = default)
public async Task<Response> RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
{
if(_username != null && _password != null){
request.SetAuth(_username, _password);
Expand Down
4 changes: 2 additions & 2 deletions src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override Response MakeRequest(TokenRequest request)
/// </summary>
/// <param name="request">Twilio response</param>
/// <returns>Task that resolves to the response</returns>
public override async Task<Response> MakeRequestAsync(TokenRequest request, CancellationToken cancellationToken = default)
public override async Task<Response> MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
{
var httpRequest = BuildHttpRequest(request);
if (!Equals(request.Method, HttpMethod.Get))
Expand All @@ -87,7 +87,7 @@ public override async Task<Response> MakeRequestAsync(TokenRequest request, Canc
// Create and return a new Response. Keep a reference to the last
// response for debugging, but don't return it as it may be shared
// among threads.
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false), httpResponse.Headers);
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers);
this.LastResponse = response;
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Twilio/Http/BearerToken/TokenHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class TokenHttpClient
/// <param name="request">request to make</param>
/// <exception>throws exception on network or connection errors.</exception>
/// <returns>response of the request</returns>
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(TokenRequest request, CancellationToken cancellationToken = Default);
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default);
#endif

}
Expand Down
2 changes: 1 addition & 1 deletion src/Twilio/Http/HttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class HttpClient
/// <param name="request">request to make</param>
/// <exception>throws exception on network or connection errors.</exception>
/// <returns>response of the request</returns>
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(Request request, CancellationToken cancellationToken = default);
public abstract System.Threading.Tasks.Task<Response> MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
#endif

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Twilio/Http/SystemNetHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override Response MakeRequest(Request request)
/// </summary>
/// <param name="request">Twilio response</param>
/// <returns>Task that resolves to the response</returns>
public override async Task<Response> MakeRequestAsync(Request request, CancellationToken cancellationToken = default)
public override async Task<Response> MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
{
var httpRequest = BuildHttpRequest(request);
if (!Equals(request.Method, HttpMethod.Get))
Expand All @@ -82,7 +82,7 @@ public override async Task<Response> MakeRequestAsync(Request request, Cancellat
// Create and return a new Response. Keep a reference to the last
// response for debugging, but don't return it as it may be shared
// among threads.
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false), httpResponse.Headers);
var response = new Response(httpResponse.StatusCode, await reader.ReadToEndAsync().ConfigureAwait(false), httpResponse.Headers);
this.LastResponse = response;
return response;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static AuthTokenPromotionResource Update(UpdateAuthTokenPromotionOptions
#if !NET35
public static async System.Threading.Tasks.Task<AuthTokenPromotionResource> UpdateAsync(UpdateAuthTokenPromotionOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
Expand All @@ -92,7 +92,7 @@ public static AuthTokenPromotionResource Update(
/// <returns> Task that resolves to A single instance of AuthTokenPromotion </returns>
public static async System.Threading.Tasks.Task<AuthTokenPromotionResource> UpdateAsync(
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
System.Threading.CancellationToken cancellationToken = default)
{
var options = new UpdateAuthTokenPromotionOptions(){ };
return await UpdateAsync(options, client, cancellationToken);
Expand Down
5 changes: 3 additions & 2 deletions src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static BulkConsentsResource Create(CreateBulkConsentsOptions options, ITw
/// <param name="options"> Create BulkConsents parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of BulkConsents </returns>
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
Expand All @@ -93,7 +93,8 @@ public static BulkConsentsResource Create(
/// <returns> Task that resolves to A single instance of BulkConsents </returns>
public static async System.Threading.Tasks.Task<BulkConsentsResource> CreateAsync(
List<object> items,
ITwilioRestClient client = null)
ITwilioRestClient client = null,
System.Threading.CancellationToken cancellationToken = default)
{
var options = new CreateBulkConsentsOptions(items){ };
return await CreateAsync(options, client, cancellationToken);
Expand Down
5 changes: 3 additions & 2 deletions src/Twilio/Rest/Accounts/V1/BulkContactsResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static BulkContactsResource Create(CreateBulkContactsOptions options, ITw
/// <param name="options"> Create BulkContacts parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of BulkContacts </returns>
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(CreateBulkContactsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(CreateBulkContactsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
Expand All @@ -93,7 +93,8 @@ public static BulkContactsResource Create(
/// <returns> Task that resolves to A single instance of BulkContacts </returns>
public static async System.Threading.Tasks.Task<BulkContactsResource> CreateAsync(
List<object> items,
ITwilioRestClient client = null)
ITwilioRestClient client = null,
System.Threading.CancellationToken cancellationToken = default)
{
var options = new CreateBulkContactsOptions(items){ };
return await CreateAsync(options, client, cancellationToken);
Expand Down
23 changes: 13 additions & 10 deletions src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient cli
/// <param name="options"> Create Aws parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
Expand Down Expand Up @@ -101,7 +101,8 @@ public static async System.Threading.Tasks.Task<AwsResource> CreateAsync(
string credentials,
string friendlyName = null,
string accountSid = null,
ITwilioRestClient client = null)
ITwilioRestClient client = null,
System.Threading.CancellationToken cancellationToken = default)
{
var options = new CreateAwsOptions(credentials){ FriendlyName = friendlyName, AccountSid = accountSid };
return await CreateAsync(options, client, cancellationToken);
Expand Down Expand Up @@ -147,7 +148,7 @@ public static bool Delete(DeleteAwsOptions options, ITwilioRestClient client = n
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteAwsOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildDeleteRequest(options, client), cancellationToken);
Expand All @@ -170,7 +171,7 @@ public static bool Delete(string pathSid, ITwilioRestClient client = null)
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the AWS resource to delete. </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
var options = new DeleteAwsOptions(pathSid) ;
return await DeleteAsync(options, client, cancellationToken);
Expand Down Expand Up @@ -210,7 +211,7 @@ public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient clien
/// <param name="options"> Fetch Aws parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildFetchRequest(options, client), cancellationToken);
Expand All @@ -234,7 +235,7 @@ public static AwsResource Fetch(
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the AWS resource to fetch. </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<AwsResource> FetchAsync(string pathSid, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
var options = new FetchAwsOptions(pathSid){ };
return await FetchAsync(options, client, cancellationToken);
Expand Down Expand Up @@ -272,7 +273,7 @@ public static ResourceSet<AwsResource> Read(ReadAwsOptions options, ITwilioRestC
/// <param name="options"> Read Aws parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Aws </returns>
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildReadRequest(options, client), cancellationToken);
Expand Down Expand Up @@ -304,7 +305,8 @@ public static ResourceSet<AwsResource> Read(
public static async System.Threading.Tasks.Task<ResourceSet<AwsResource>> ReadAsync(
int? pageSize = null,
long? limit = null,
ITwilioRestClient client = null)
ITwilioRestClient client = null,
System.Threading.CancellationToken cancellationToken = default)
{
var options = new ReadAwsOptions(){ PageSize = pageSize, Limit = limit};
return await ReadAsync(options, client, cancellationToken);
Expand Down Expand Up @@ -396,7 +398,7 @@ public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient cli
#if !NET35
public static async System.Threading.Tasks.Task<AwsResource> UpdateAsync(UpdateAwsOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
Expand Down Expand Up @@ -427,7 +429,8 @@ public static AwsResource Update(
public static async System.Threading.Tasks.Task<AwsResource> UpdateAsync(
string pathSid,
string friendlyName = null,
ITwilioRestClient client = null)
ITwilioRestClient client = null,
System.Threading.CancellationToken cancellationToken = default)
{
var options = new UpdateAwsOptions(pathSid){ FriendlyName = friendlyName };
return await UpdateAsync(options, client, cancellationToken);
Expand Down
Loading

0 comments on commit 5a3c480

Please sign in to comment.