Skip to content

Commit

Permalink
Bulk Regex Add of CancellationToken Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
joewashear007 authored Jan 10, 2025
1 parent 58d3037 commit 5313061
Show file tree
Hide file tree
Showing 155 changed files with 1,677 additions and 1,545 deletions.
12 changes: 6 additions & 6 deletions src/Twilio/Rest/PreviewIam/Organizations/AccountResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public static AccountResource Fetch(FetchAccountOptions options, ITwilioRestClie
/// <param name="options"> Fetch Account parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Account </returns>
public static async System.Threading.Tasks.Task<AccountResource> FetchAsync(FetchAccountOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<AccountResource> FetchAsync(FetchAccountOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildFetchRequest(options, client));
var response = await client.RequestAsync(BuildFetchRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand All @@ -114,7 +114,7 @@ public static AccountResource Fetch(
public static async System.Threading.Tasks.Task<AccountResource> FetchAsync(string pathOrganizationSid, string pathAccountSid, ITwilioRestClient client = null)
{
var options = new FetchAccountOptions(pathOrganizationSid, pathAccountSid){ };
return await FetchAsync(options, client);
return await FetchAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -151,10 +151,10 @@ public static ResourceSet<AccountResource> Read(ReadAccountOptions options, ITwi
/// <param name="options"> Read Account parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Account </returns>
public static async System.Threading.Tasks.Task<ResourceSet<AccountResource>> ReadAsync(ReadAccountOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<ResourceSet<AccountResource>> ReadAsync(ReadAccountOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildReadRequest(options, client));
var response = await client.RequestAsync(BuildReadRequest(options, client), cancellationToken);

var page = Page<AccountResource>.FromJson("content", response.Content);
return new ResourceSet<AccountResource>(page, options, client);
Expand Down Expand Up @@ -190,7 +190,7 @@ public static async System.Threading.Tasks.Task<ResourceSet<AccountResource>> Re
ITwilioRestClient client = null)
{
var options = new ReadAccountOptions(pathOrganizationSid){ PageSize = pageSize, Limit = limit};
return await ReadAsync(options, client);
return await ReadAsync(options, client, cancellationToken);
}
#endif

Expand Down
21 changes: 11 additions & 10 deletions src/Twilio/Rest/PreviewIam/Organizations/RoleAssignmentResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public static RoleAssignmentResource Create(CreateRoleAssignmentOptions options,
/// <param name="options"> Create RoleAssignment parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of RoleAssignment </returns>
public static async System.Threading.Tasks.Task<RoleAssignmentResource> CreateAsync(CreateRoleAssignmentOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<RoleAssignmentResource> CreateAsync(CreateRoleAssignmentOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client));
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand Down Expand Up @@ -139,7 +139,7 @@ public static async System.Threading.Tasks.Task<RoleAssignmentResource> CreateAs
ITwilioRestClient client = null)
{
var options = new CreateRoleAssignmentOptions(pathOrganizationSid, publicApiCreateRoleAssignmentRequest){ };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -182,11 +182,12 @@ public static bool Delete(DeleteRoleAssignmentOptions options, ITwilioRestClient
/// <param name="options"> Delete RoleAssignment parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of RoleAssignment </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteRoleAssignmentOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteRoleAssignmentOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildDeleteRequest(options, client));
var response = await client.RequestAsync(BuildDeleteRequest(options, client), cancellationToken);
return response.StatusCode == System.Net.HttpStatusCode.NoContent;
}
#endif
Expand All @@ -211,7 +212,7 @@ public static bool Delete(string pathOrganizationSid, string pathRoleAssignmentS
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathOrganizationSid, string pathRoleAssignmentSid, ITwilioRestClient client = null)
{
var options = new DeleteRoleAssignmentOptions(pathOrganizationSid, pathRoleAssignmentSid) ;
return await DeleteAsync(options, client);
return await DeleteAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -248,10 +249,10 @@ public static ResourceSet<RoleAssignmentResource> Read(ReadRoleAssignmentOptions
/// <param name="options"> Read RoleAssignment parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of RoleAssignment </returns>
public static async System.Threading.Tasks.Task<ResourceSet<RoleAssignmentResource>> ReadAsync(ReadRoleAssignmentOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<ResourceSet<RoleAssignmentResource>> ReadAsync(ReadRoleAssignmentOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildReadRequest(options, client));
var response = await client.RequestAsync(BuildReadRequest(options, client), cancellationToken);

var page = Page<RoleAssignmentResource>.FromJson("content", response.Content);
return new ResourceSet<RoleAssignmentResource>(page, options, client);
Expand Down Expand Up @@ -295,7 +296,7 @@ public static async System.Threading.Tasks.Task<ResourceSet<RoleAssignmentResour
ITwilioRestClient client = null)
{
var options = new ReadRoleAssignmentOptions(pathOrganizationSid){ PageSize = pageSize, Identity = identity, Scope = scope, Limit = limit};
return await ReadAsync(options, client);
return await ReadAsync(options, client, cancellationToken);
}
#endif

Expand Down
36 changes: 19 additions & 17 deletions src/Twilio/Rest/PreviewIam/Organizations/UserResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ public static UserResource Create(CreateUserOptions options, ITwilioRestClient c
/// <param name="options"> Create User parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of User </returns>
public static async System.Threading.Tasks.Task<UserResource> CreateAsync(CreateUserOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<UserResource> CreateAsync(CreateUserOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client));
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand Down Expand Up @@ -303,7 +303,7 @@ public static async System.Threading.Tasks.Task<UserResource> CreateAsync(
ITwilioRestClient client = null)
{
var options = new CreateUserOptions(pathOrganizationSid, scimUser){ };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -346,11 +346,12 @@ public static bool Delete(DeleteUserOptions options, ITwilioRestClient client =
/// <param name="options"> Delete User parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of User </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteUserOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteUserOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildDeleteRequest(options, client));
var response = await client.RequestAsync(BuildDeleteRequest(options, client), cancellationToken);
return response.StatusCode == System.Net.HttpStatusCode.NoContent;
}
#endif
Expand All @@ -375,7 +376,7 @@ public static bool Delete(string pathOrganizationSid, string pathUserSid, ITwili
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathOrganizationSid, string pathUserSid, ITwilioRestClient client = null)
{
var options = new DeleteUserOptions(pathOrganizationSid, pathUserSid) ;
return await DeleteAsync(options, client);
return await DeleteAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -414,10 +415,10 @@ public static UserResource Fetch(FetchUserOptions options, ITwilioRestClient cli
/// <param name="options"> Fetch User parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of User </returns>
public static async System.Threading.Tasks.Task<UserResource> FetchAsync(FetchUserOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<UserResource> FetchAsync(FetchUserOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildFetchRequest(options, client));
var response = await client.RequestAsync(BuildFetchRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand All @@ -444,7 +445,7 @@ public static UserResource Fetch(
public static async System.Threading.Tasks.Task<UserResource> FetchAsync(string pathOrganizationSid, string pathUserSid, ITwilioRestClient client = null)
{
var options = new FetchUserOptions(pathOrganizationSid, pathUserSid){ };
return await FetchAsync(options, client);
return await FetchAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -481,10 +482,10 @@ public static ResourceSet<UserResource> Read(ReadUserOptions options, ITwilioRes
/// <param name="options"> Read User parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of User </returns>
public static async System.Threading.Tasks.Task<ResourceSet<UserResource>> ReadAsync(ReadUserOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<ResourceSet<UserResource>> ReadAsync(ReadUserOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildReadRequest(options, client));
var response = await client.RequestAsync(BuildReadRequest(options, client), cancellationToken);

var page = Page<UserResource>.FromJson("Resources", response.Content);
return new ResourceSet<UserResource>(page, options, client);
Expand Down Expand Up @@ -520,7 +521,7 @@ public static async System.Threading.Tasks.Task<ResourceSet<UserResource>> ReadA
ITwilioRestClient client = null)
{
var options = new ReadUserOptions(pathOrganizationSid){ Filter = filter, Limit = limit};
return await ReadAsync(options, client);
return await ReadAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -610,11 +611,12 @@ public static UserResource Update(UpdateUserOptions options, ITwilioRestClient c
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of User </returns>
#if !NET35
public static async System.Threading.Tasks.Task<UserResource> UpdateAsync(UpdateUserOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<UserResource> UpdateAsync(UpdateUserOptions options,
ITwilioRestClient client = null,
CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
var response = await client.RequestAsync(BuildUpdateRequest(options, client));
var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand Down Expand Up @@ -653,7 +655,7 @@ public static async System.Threading.Tasks.Task<UserResource> UpdateAsync(
ITwilioRestClient client = null)
{
var options = new UpdateUserOptions(pathOrganizationSid, pathUserSid, scimUser){ IfMatch = ifMatch };
return await UpdateAsync(options, client);
return await UpdateAsync(options, client, cancellationToken);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/Twilio/Rest/PreviewIam/V1/AuthorizeResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public static AuthorizeResource Fetch(FetchAuthorizeOptions options, ITwilioRest
/// <param name="options"> Fetch Authorize parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Authorize </returns>
public static async System.Threading.Tasks.Task<AuthorizeResource> FetchAsync(FetchAuthorizeOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<AuthorizeResource> FetchAsync(FetchAuthorizeOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetNoAuthRestClient();
var response = await client.RequestAsync(BuildFetchRequest(options, client));
var response = await client.RequestAsync(BuildFetchRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand Down Expand Up @@ -104,7 +104,7 @@ public static AuthorizeResource Fetch(
public static async System.Threading.Tasks.Task<AuthorizeResource> FetchAsync(string responseType = null, string clientId = null, string redirectUri = null, string scope = null, string state = null, ITwilioRestClient client = null)
{
var options = new FetchAuthorizeOptions(){ ResponseType = responseType,ClientId = clientId,RedirectUri = redirectUri,Scope = scope,State = state };
return await FetchAsync(options, client);
return await FetchAsync(options, client, cancellationToken);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/Twilio/Rest/PreviewIam/V1/TokenResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public static TokenResource Create(CreateTokenOptions options, ITwilioRestClient
/// <param name="options"> Create Token parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Token </returns>
public static async System.Threading.Tasks.Task<TokenResource> CreateAsync(CreateTokenOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<TokenResource> CreateAsync(CreateTokenOptions options, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetNoAuthRestClient();
var response = await client.RequestAsync(BuildCreateRequest(options, client));
var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
Expand Down Expand Up @@ -124,7 +124,7 @@ public static async System.Threading.Tasks.Task<TokenResource> CreateAsync(
ITwilioRestClient client = null)
{
var options = new CreateTokenOptions(grantType, clientId){ ClientSecret = clientSecret, Code = code, RedirectUri = redirectUri, Audience = audience, RefreshToken = refreshToken, Scope = scope };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down
Loading

0 comments on commit 5313061

Please sign in to comment.