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 8713861 commit 58d3037
Show file tree
Hide file tree
Showing 65 changed files with 733 additions and 674 deletions.
40 changes: 21 additions & 19 deletions src/Twilio/Rest/Notify/V1/CredentialResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public static CredentialResource Create(CreateCredentialOptions options, ITwilio
/// <param name="options"> Create Credential parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<CredentialResource> CreateAsync(CreateCredentialOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<CredentialResource> CreateAsync(CreateCredentialOptions 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 @@ -134,7 +134,7 @@ public static async System.Threading.Tasks.Task<CredentialResource> CreateAsync(
ITwilioRestClient client = null)
{
var options = new CreateCredentialOptions(type){ FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -175,11 +175,12 @@ public static bool Delete(DeleteCredentialOptions options, ITwilioRestClient cli
/// <param name="options"> Delete Credential parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteCredentialOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteCredentialOptions 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 @@ -199,10 +200,10 @@ public static bool Delete(string pathSid, ITwilioRestClient client = null)
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the Credential resource to delete. </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
var options = new DeleteCredentialOptions(pathSid) ;
return await DeleteAsync(options, client);
return await DeleteAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -239,10 +240,10 @@ public static CredentialResource Fetch(FetchCredentialOptions options, ITwilioRe
/// <param name="options"> Fetch Credential parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<CredentialResource> FetchAsync(FetchCredentialOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<CredentialResource> FetchAsync(FetchCredentialOptions 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 @@ -263,10 +264,10 @@ public static CredentialResource Fetch(
/// <param name="pathSid"> The Twilio-provided string that uniquely identifies the Credential resource to fetch. </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<CredentialResource> FetchAsync(string pathSid, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<CredentialResource> FetchAsync(string pathSid, ITwilioRestClient client = null, CancellationToken cancellationToken = default)
{
var options = new FetchCredentialOptions(pathSid){ };
return await FetchAsync(options, client);
return await FetchAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -301,10 +302,10 @@ public static ResourceSet<CredentialResource> Read(ReadCredentialOptions options
/// <param name="options"> Read Credential parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
public static async System.Threading.Tasks.Task<ResourceSet<CredentialResource>> ReadAsync(ReadCredentialOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<ResourceSet<CredentialResource>> ReadAsync(ReadCredentialOptions 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<CredentialResource>.FromJson("credentials", response.Content);
return new ResourceSet<CredentialResource>(page, options, client);
Expand Down Expand Up @@ -336,7 +337,7 @@ public static async System.Threading.Tasks.Task<ResourceSet<CredentialResource>>
ITwilioRestClient client = null)
{
var options = new ReadCredentialOptions(){ PageSize = pageSize, Limit = limit};
return await ReadAsync(options, client);
return await ReadAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -423,11 +424,12 @@ public static CredentialResource Update(UpdateCredentialOptions options, ITwilio
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Credential </returns>
#if !NET35
public static async System.Threading.Tasks.Task<CredentialResource> UpdateAsync(UpdateCredentialOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<CredentialResource> UpdateAsync(UpdateCredentialOptions 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 @@ -478,7 +480,7 @@ public static async System.Threading.Tasks.Task<CredentialResource> UpdateAsync(
ITwilioRestClient client = null)
{
var options = new UpdateCredentialOptions(pathSid){ FriendlyName = friendlyName, Certificate = certificate, PrivateKey = privateKey, Sandbox = sandbox, ApiKey = apiKey, Secret = secret };
return await UpdateAsync(options, client);
return await UpdateAsync(options, client, cancellationToken);
}
#endif

Expand Down
27 changes: 14 additions & 13 deletions src/Twilio/Rest/Notify/V1/Service/BindingResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public static BindingResource Create(CreateBindingOptions options, ITwilioRestCl
/// <param name="options"> Create Binding parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Binding </returns>
public static async System.Threading.Tasks.Task<BindingResource> CreateAsync(CreateBindingOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<BindingResource> CreateAsync(CreateBindingOptions 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 @@ -142,7 +142,7 @@ public static async System.Threading.Tasks.Task<BindingResource> CreateAsync(
ITwilioRestClient client = null)
{
var options = new CreateBindingOptions(pathServiceSid, identity, bindingType, address){ Tag = tag, NotificationProtocolVersion = notificationProtocolVersion, CredentialSid = credentialSid, Endpoint = endpoint };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -185,11 +185,12 @@ public static bool Delete(DeleteBindingOptions options, ITwilioRestClient client
/// <param name="options"> Delete Binding parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Binding </returns>
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteBindingOptions options,
ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<bool> DeleteAsync(DeleteBindingOptions 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 @@ -214,7 +215,7 @@ public static bool Delete(string pathServiceSid, string pathSid, ITwilioRestClie
public static async System.Threading.Tasks.Task<bool> DeleteAsync(string pathServiceSid, string pathSid, ITwilioRestClient client = null)
{
var options = new DeleteBindingOptions(pathServiceSid, pathSid) ;
return await DeleteAsync(options, client);
return await DeleteAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -253,10 +254,10 @@ public static BindingResource Fetch(FetchBindingOptions options, ITwilioRestClie
/// <param name="options"> Fetch Binding parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Binding </returns>
public static async System.Threading.Tasks.Task<BindingResource> FetchAsync(FetchBindingOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<BindingResource> FetchAsync(FetchBindingOptions 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 @@ -283,7 +284,7 @@ public static BindingResource Fetch(
public static async System.Threading.Tasks.Task<BindingResource> FetchAsync(string pathServiceSid, string pathSid, ITwilioRestClient client = null)
{
var options = new FetchBindingOptions(pathServiceSid, pathSid){ };
return await FetchAsync(options, client);
return await FetchAsync(options, client, cancellationToken);
}
#endif

Expand Down Expand Up @@ -320,10 +321,10 @@ public static ResourceSet<BindingResource> Read(ReadBindingOptions options, ITwi
/// <param name="options"> Read Binding parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Binding </returns>
public static async System.Threading.Tasks.Task<ResourceSet<BindingResource>> ReadAsync(ReadBindingOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<ResourceSet<BindingResource>> ReadAsync(ReadBindingOptions 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<BindingResource>.FromJson("bindings", response.Content);
return new ResourceSet<BindingResource>(page, options, client);
Expand Down Expand Up @@ -375,7 +376,7 @@ public static async System.Threading.Tasks.Task<ResourceSet<BindingResource>> Re
ITwilioRestClient client = null)
{
var options = new ReadBindingOptions(pathServiceSid){ StartDate = startDate, EndDate = endDate, Identity = identity, Tag = tag, PageSize = pageSize, Limit = limit};
return await ReadAsync(options, client);
return await ReadAsync(options, client, cancellationToken);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/Twilio/Rest/Notify/V1/Service/NotificationResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public static NotificationResource Create(CreateNotificationOptions options, ITw
/// <param name="options"> Create Notification parameters </param>
/// <param name="client"> Client to make requests to Twilio </param>
/// <returns> Task that resolves to A single instance of Notification </returns>
public static async System.Threading.Tasks.Task<NotificationResource> CreateAsync(CreateNotificationOptions options, ITwilioRestClient client = null)
public static async System.Threading.Tasks.Task<NotificationResource> CreateAsync(CreateNotificationOptions 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 @@ -183,7 +183,7 @@ public static async System.Threading.Tasks.Task<NotificationResource> CreateAsyn
ITwilioRestClient client = null)
{
var options = new CreateNotificationOptions(pathServiceSid){ Identity = identity, Tag = tag, Body = body, Priority = priority, Ttl = ttl, Title = title, Sound = sound, Action = action, Data = data, Apn = apn, Gcm = gcm, Sms = sms, FacebookMessenger = facebookMessenger, Fcm = fcm, Segment = segment, Alexa = alexa, ToBinding = toBinding, DeliveryCallbackUrl = deliveryCallbackUrl };
return await CreateAsync(options, client);
return await CreateAsync(options, client, cancellationToken);
}
#endif

Expand Down
Loading

0 comments on commit 58d3037

Please sign in to comment.