From 71943203cdff3015f888ec561a3476b4fa82760e Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Fri, 17 May 2019 19:23:21 +0000 Subject: [PATCH] .NET SDK Resource Provider:'Billing' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/6010' REST Spec PR Author 'sarang-amondikar' REST Spec PR Last commit --- ...illingAccountsValidateAddressOperations.cs | 244 ++++++++++++++++++ ...untsValidateAddressOperationsExtensions.cs | 63 +++++ .../Generated/BillingManagementClient.cs | 6 + ...illingAccountsValidateAddressOperations.cs | 51 ++++ .../Generated/IBillingManagementClient.cs | 5 + .../Models/AddressValidationStatus.cs | 22 ++ .../Models/ValidateAddressResponse.cs | 72 ++++++ .../SdkInfo_BillingManagementClient.cs | 1 + 8 files changed, 464 insertions(+) create mode 100644 src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperationsExtensions.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/IBillingAccountsValidateAddressOperations.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/AddressValidationStatus.cs create mode 100644 src/SDKs/Billing/Management.Billing/Generated/Models/ValidateAddressResponse.cs diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperations.cs new file mode 100644 index 000000000000..bc198f574f60 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperations.cs @@ -0,0 +1,244 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BillingAccountsValidateAddressOperations operations. + /// + internal partial class BillingAccountsValidateAddressOperations : IServiceOperations, IBillingAccountsValidateAddressOperations + { + /// + /// Initializes a new instance of the BillingAccountsValidateAddressOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BillingAccountsValidateAddressOperations(BillingManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the BillingManagementClient + /// + public BillingManagementClient Client { get; private set; } + + /// + /// Validates the address. + /// + /// + /// billing Account Id. + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> PostWithHttpMessagesAsync(string billingAccountName, Address address, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (address == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "address"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("address", address); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Post", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validateAddress").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(address != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(address, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperationsExtensions.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperationsExtensions.cs new file mode 100644 index 000000000000..1b585e79e304 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingAccountsValidateAddressOperationsExtensions.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BillingAccountsValidateAddressOperations. + /// + public static partial class BillingAccountsValidateAddressOperationsExtensions + { + /// + /// Validates the address. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// + public static ValidateAddressResponse Post(this IBillingAccountsValidateAddressOperations operations, string billingAccountName, Address address) + { + return operations.PostAsync(billingAccountName, address).GetAwaiter().GetResult(); + } + + /// + /// Validates the address. + /// + /// + /// The operations group for this extension method. + /// + /// + /// billing Account Id. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task PostAsync(this IBillingAccountsValidateAddressOperations operations, string billingAccountName, Address address, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PostWithHttpMessagesAsync(billingAccountName, address, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs index a93d402253d4..e864df5c8123 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs @@ -81,6 +81,11 @@ public partial class BillingManagementClient : ServiceClient public virtual IBillingAccountsOperations BillingAccounts { get; private set; } + /// + /// Gets the IBillingAccountsValidateAddressOperations. + /// + public virtual IBillingAccountsValidateAddressOperations BillingAccountsValidateAddress { get; private set; } + /// /// Gets the IAvailableBalancesOperations. /// @@ -423,6 +428,7 @@ public BillingManagementClient(System.Uri baseUri, ServiceClientCredentials cred private void Initialize() { BillingAccounts = new BillingAccountsOperations(this); + BillingAccountsValidateAddress = new BillingAccountsValidateAddressOperations(this); AvailableBalances = new AvailableBalancesOperations(this); PaymentMethods = new PaymentMethodsOperations(this); BillingProfiles = new BillingProfilesOperations(this); diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingAccountsValidateAddressOperations.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingAccountsValidateAddressOperations.cs new file mode 100644 index 000000000000..b78a41362673 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingAccountsValidateAddressOperations.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BillingAccountsValidateAddressOperations operations. + /// + public partial interface IBillingAccountsValidateAddressOperations + { + /// + /// Validates the address. + /// + /// + /// billing Account Id. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> PostWithHttpMessagesAsync(string billingAccountName, Address address, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs index 27fea6f40869..25a6d3c84a32 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/IBillingManagementClient.cs @@ -76,6 +76,11 @@ public partial interface IBillingManagementClient : System.IDisposable /// IBillingAccountsOperations BillingAccounts { get; } + /// + /// Gets the IBillingAccountsValidateAddressOperations. + /// + IBillingAccountsValidateAddressOperations BillingAccountsValidateAddress { get; } + /// /// Gets the IAvailableBalancesOperations. /// diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/AddressValidationStatus.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/AddressValidationStatus.cs new file mode 100644 index 000000000000..41d215933e7e --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/AddressValidationStatus.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing.Models +{ + + /// + /// Defines values for AddressValidationStatus. + /// + public static class AddressValidationStatus + { + public const string Valid = "Valid"; + public const string Invalid = "Invalid"; + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/Models/ValidateAddressResponse.cs b/src/SDKs/Billing/Management.Billing/Generated/Models/ValidateAddressResponse.cs new file mode 100644 index 000000000000..8e6b3487d409 --- /dev/null +++ b/src/SDKs/Billing/Management.Billing/Generated/Models/ValidateAddressResponse.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Billing.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the address validation + /// + public partial class ValidateAddressResponse + { + /// + /// Initializes a new instance of the ValidateAddressResponse class. + /// + public ValidateAddressResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ValidateAddressResponse class. + /// + /// status of the address validation. Possible + /// values include: 'Valid', 'Invalid' + /// list of suggested + /// addresses. + /// Validation error message. + public ValidateAddressResponse(string status = default(string), IList
suggestedAddresses = default(IList
), string validationMessage = default(string)) + { + Status = status; + SuggestedAddresses = suggestedAddresses; + ValidationMessage = validationMessage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets status of the address validation. Possible values + /// include: 'Valid', 'Invalid' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets list of suggested addresses. + /// + [JsonProperty(PropertyName = "suggestedAddresses")] + public IList
SuggestedAddresses { get; set; } + + /// + /// Gets or sets validation error message. + /// + [JsonProperty(PropertyName = "validationMessage")] + public string ValidationMessage { get; set; } + + } +} diff --git a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs index ea1bcebcf0bd..fffc013404a4 100644 --- a/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs +++ b/src/SDKs/Billing/Management.Billing/Generated/SdkInfo_BillingManagementClient.cs @@ -22,6 +22,7 @@ public static IEnumerable> ApiInfo_BillingManageme new Tuple("Billing", "Agreements", "2018-11-01-preview"), new Tuple("Billing", "AvailableBalances", "2018-11-01-preview"), new Tuple("Billing", "BillingAccounts", "2018-11-01-preview"), + new Tuple("Billing", "BillingAccountsValidateAddress", "2018-11-01-preview"), new Tuple("Billing", "BillingPermissions", "2018-11-01-preview"), new Tuple("Billing", "BillingProfiles", "2018-11-01-preview"), new Tuple("Billing", "BillingProperty", "2018-11-01-preview"),