diff --git a/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs b/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs index 92f562834..461fa72a3 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/AwsOptions.cs @@ -25,7 +25,7 @@ namespace Twilio.Rest.Accounts.V1.Credential { /// Create a new AWS Credential - public class CreateAwsOptions : IOptions + public class CreateAwsOptions : IOptions { /// A string that contains the AWS access credentials in the format `:`. For example, `AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` @@ -101,7 +101,7 @@ public List> GetParams() /// Fetch the AWS credentials specified by the provided Credential Sid - public class FetchAwsOptions : IOptions + public class FetchAwsOptions : IOptions { /// The Twilio-provided string that uniquely identifies the AWS resource to fetch. @@ -131,7 +131,7 @@ public List> GetParams() /// Retrieves a collection of AWS Credentials belonging to the account used to make the request - public class ReadAwsOptions : ReadOptions + public class ReadAwsOptions : ReadOptions { @@ -155,7 +155,7 @@ public List> GetParams() } /// Modify the properties of a given Account - public class UpdateAwsOptions : IOptions + public class UpdateAwsOptions : IOptions { /// The Twilio-provided string that uniquely identifies the AWS resource to update. diff --git a/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs b/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs index 4af96ba0a..21b3952a8 100644 --- a/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs +++ b/src/Twilio/Rest/Accounts/V1/Credential/AwsResource.cs @@ -24,16 +24,191 @@ using Twilio.Http; - namespace Twilio.Rest.Accounts.V1.Credential { + +public class AwsCreateResource : Resource +{ + /// The unique string that we created to identify the AWS resource. + [JsonProperty("sid")] + public string Sid { get; private set; } + + /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + + /// The string that you assigned to describe the resource. + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + + /// The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + /// The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + /// The URI for this resource, relative to `https://accounts.twilio.com` + [JsonProperty("url")] + public Uri Url { get; private set; } + + public static AwsCreateResource FromJson(string json) { + try { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } + public static string ToJson(object model) { + try { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } +} + public class AwsFetchResource : Resource +{ + /// The unique string that we created to identify the AWS resource. + [JsonProperty("sid")] + public string Sid { get; private set; } + + /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + + /// The string that you assigned to describe the resource. + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + + /// The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + /// The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + /// The URI for this resource, relative to `https://accounts.twilio.com` + [JsonProperty("url")] + public Uri Url { get; private set; } + + + public static AwsFetchResource FromJson(string json) { + try { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } + public static string ToJson(object model) { + try { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } +} + public class AwsReadResource : Resource +{ + /// The unique string that we created to identify the AWS resource. + [JsonProperty("sid")] + public string Sid { get; private set; } + + /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + + /// The string that you assigned to describe the resource. + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + + /// The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + /// The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + /// The URI for this resource, relative to `https://accounts.twilio.com` + [JsonProperty("url")] + public Uri Url { get; private set; } + + public static AwsReadResource FromJson(string json) { + try { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } + public static string ToJson(object model) { + try { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } +} + public class AwsUpdateResource : Resource +{ + /// The unique string that we created to identify the AWS resource. + [JsonProperty("sid")] + public string Sid { get; private set; } + + /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. + [JsonProperty("account_sid")] + public string AccountSid { get; private set; } + + /// The string that you assigned to describe the resource. + [JsonProperty("friendly_name")] + public string FriendlyName { get; private set; } + + /// The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_created")] + public DateTime? DateCreated { get; private set; } + + /// The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + [JsonProperty("date_updated")] + public DateTime? DateUpdated { get; private set; } + + /// The URI for this resource, relative to `https://accounts.twilio.com` + [JsonProperty("url")] + public Uri Url { get; private set; } + + + public static AwsUpdateResource FromJson(string json) { + try { + return JsonConvert.DeserializeObject(json); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } + public static string ToJson(object model) { + try { + return JsonConvert.SerializeObject(model); + } + catch (JsonException e) { + throw new ApiException(e.Message, e); + } + } +} + public class AwsResource : Resource { - + private static Request BuildCreateRequest(CreateAwsOptions options, ITwilioRestClient client) { @@ -54,11 +229,11 @@ private static Request BuildCreateRequest(CreateAwsOptions options, ITwilioRestC /// Create Aws parameters /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient client = null) + public static AwsCreateResource Create(CreateAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildCreateRequest(options, client)); - return FromJson(response.Content); + return AwsCreateResource.FromJson(response.Content); } #if !NET35 @@ -66,11 +241,11 @@ public static AwsResource Create(CreateAwsOptions options, ITwilioRestClient cli /// Create Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task CreateAsync(CreateAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); - return FromJson(response.Content); + return AwsCreateResource.FromJson(response.Content); } #endif @@ -80,7 +255,7 @@ public static async System.Threading.Tasks.Task CreateAsync(CreateA /// The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request. /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Create( + public static AwsCreateResource Create( string credentials, string friendlyName = null, string accountSid = null, @@ -97,7 +272,7 @@ public static AwsResource Create( /// The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request. /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task CreateAsync( + public static async System.Threading.Tasks.Task CreateAsync( string credentials, string friendlyName = null, string accountSid = null, @@ -108,7 +283,7 @@ public static async System.Threading.Tasks.Task CreateAsync( } #endif - + /// Delete a Credential from your account /// Delete Aws parameters /// Client to make requests to Twilio @@ -176,7 +351,7 @@ public static async System.Threading.Tasks.Task DeleteAsync(string pathSid return await DeleteAsync(options, client); } #endif - + private static Request BuildFetchRequest(FetchAwsOptions options, ITwilioRestClient client) { @@ -198,11 +373,11 @@ private static Request BuildFetchRequest(FetchAwsOptions options, ITwilioRestCli /// Fetch Aws parameters /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient client = null) + public static AwsFetchResource Fetch(FetchAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildFetchRequest(options, client)); - return FromJson(response.Content); + return AwsFetchResource.FromJson(response.Content); } #if !NET35 @@ -210,18 +385,18 @@ public static AwsResource Fetch(FetchAwsOptions options, ITwilioRestClient clien /// Fetch Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(FetchAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); - return FromJson(response.Content); + return AwsFetchResource.FromJson(response.Content); } #endif /// Fetch the AWS credentials specified by the provided Credential Sid /// The Twilio-provided string that uniquely identifies the AWS resource to fetch. /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Fetch( + public static AwsFetchResource Fetch( string pathSid, ITwilioRestClient client = null) { @@ -234,13 +409,13 @@ public static AwsResource Fetch( /// The Twilio-provided string that uniquely identifies the AWS resource to fetch. /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task FetchAsync(string pathSid, ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task FetchAsync(string pathSid, ITwilioRestClient client = null) { var options = new FetchAwsOptions(pathSid){ }; return await FetchAsync(options, client); } #endif - + private static Request BuildReadRequest(ReadAwsOptions options, ITwilioRestClient client) { @@ -259,12 +434,12 @@ private static Request BuildReadRequest(ReadAwsOptions options, ITwilioRestClien /// Read Aws parameters /// Client to make requests to Twilio /// A single instance of Aws - public static ResourceSet Read(ReadAwsOptions options, ITwilioRestClient client = null) + public static ResourceSet Read(ReadAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildReadRequest(options, client)); - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); } #if !NET35 @@ -272,13 +447,13 @@ public static ResourceSet Read(ReadAwsOptions options, ITwilioRestC /// Read Aws parameters /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null) + public static async System.Threading.Tasks.Task> ReadAsync(ReadAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildReadRequest(options, client)); - var page = Page.FromJson("credentials", response.Content); - return new ResourceSet(page, options, client); + var page = Page.FromJson("credentials", response.Content); + return new ResourceSet(page, options, client); } #endif /// Retrieves a collection of AWS Credentials belonging to the account used to make the request @@ -286,7 +461,7 @@ public static async System.Threading.Tasks.Task> ReadAs /// Record limit /// Client to make requests to Twilio /// A single instance of Aws - public static ResourceSet Read( + public static ResourceSet Read( long? pageSize = null, long? limit = null, ITwilioRestClient client = null) @@ -301,7 +476,7 @@ public static ResourceSet Read( /// Record limit /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task> ReadAsync( + public static async System.Threading.Tasks.Task> ReadAsync( long? pageSize = null, long? limit = null, ITwilioRestClient client = null) @@ -359,7 +534,7 @@ public static Page PreviousPage(Page page, ITwilioRest return Page.FromJson("credentials", response.Content); } - + private static Request BuildUpdateRequest(UpdateAwsOptions options, ITwilioRestClient client) { @@ -382,11 +557,11 @@ private static Request BuildUpdateRequest(UpdateAwsOptions options, ITwilioRestC /// Update Aws parameters /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient client = null) + public static AwsUpdateResource Update(UpdateAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildUpdateRequest(options, client)); - return FromJson(response.Content); + return AwsUpdateResource.FromJson(response.Content); } /// Modify the properties of a given Account @@ -394,12 +569,12 @@ public static AwsResource Update(UpdateAwsOptions options, ITwilioRestClient cli /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws #if !NET35 - public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, + public static async System.Threading.Tasks.Task UpdateAsync(UpdateAwsOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildUpdateRequest(options, client)); - return FromJson(response.Content); + return AwsUpdateResource.FromJson(response.Content); } #endif @@ -408,7 +583,7 @@ public static async System.Threading.Tasks.Task UpdateAsync(UpdateA /// A descriptive string that you create to describe the resource. It can be up to 64 characters long. /// Client to make requests to Twilio /// A single instance of Aws - public static AwsResource Update( + public static AwsUpdateResource Update( string pathSid, string friendlyName = null, ITwilioRestClient client = null) @@ -423,7 +598,7 @@ public static AwsResource Update( /// A descriptive string that you create to describe the resource. It can be up to 64 characters long. /// Client to make requests to Twilio /// Task that resolves to A single instance of Aws - public static async System.Threading.Tasks.Task UpdateAsync( + public static async System.Threading.Tasks.Task UpdateAsync( string pathSid, string friendlyName = null, ITwilioRestClient client = null) @@ -433,70 +608,5 @@ public static async System.Threading.Tasks.Task UpdateAsync( } #endif - - /// - /// Converts a JSON string into a AwsResource object - /// - /// Raw JSON string - /// AwsResource object represented by the provided JSON - public static AwsResource FromJson(string json) - { - try - { - return JsonConvert.DeserializeObject(json); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - /// - /// Converts an object into a json string - /// - /// C# model - /// JSON string - public static string ToJson(object model) - { - try - { - return JsonConvert.SerializeObject(model); - } - catch (JsonException e) - { - throw new ApiException(e.Message, e); - } - } - - - /// The unique string that we created to identify the AWS resource. - [JsonProperty("sid")] - public string Sid { get; private set; } - - /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the AWS resource. - [JsonProperty("account_sid")] - public string AccountSid { get; private set; } - - /// The string that you assigned to describe the resource. - [JsonProperty("friendly_name")] - public string FriendlyName { get; private set; } - - /// The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - [JsonProperty("date_created")] - public DateTime? DateCreated { get; private set; } - - /// The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. - [JsonProperty("date_updated")] - public DateTime? DateUpdated { get; private set; } - - /// The URI for this resource, relative to `https://accounts.twilio.com` - [JsonProperty("url")] - public Uri Url { get; private set; } - - - - private AwsResource() { - - } } } -