-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Billing] Migrate Billing sdk to generated sdk #27198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JoyerJin
wants to merge
10
commits into
main
Choose a base branch
from
billing-sdk-migrate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
88bb7b0
generated Billing by autorest csharp
JoyerJin cbefbb2
add Microsoft.Azure.PowerShell.Billing.Management.Sdk
JoyerJin 7040781
generate Microsoft.Azure.PowerShell.Billing.Management.Sdk by autores…
JoyerJin 45cb5e5
Update Az.Billing.psd1
JoyerJin a17790b
Update BreakingChangeIssues.csv
JoyerJin 36f68d1
fix payload-flattening-threshold
JoyerJin 942da00
Update ChangeLog.md
JoyerJin 534232f
sync up autorest generated code
JoyerJin c9a4257
Update ChangeLog.md
JoyerJin 2824473
Revert "Update BreakingChangeIssues.csv"
JoyerJin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/Billing/Billing.Management.Sdk/Billing.Management.Sdk.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <PsModuleName>Billing</PsModuleName> | ||
| </PropertyGroup> | ||
| <Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" /> | ||
| <PropertyGroup> | ||
| <TargetFramework>netstandard2.0</TargetFramework> | ||
| <AssemblyName>Microsoft.Azure.PowerShell.Billing.Management.Sdk</AssemblyName> | ||
| <RootNamespace>Microsoft.Azure.Management.Billing</RootNamespace> | ||
| <NoWarn>$(NoWarn);CS0108;CS1573</NoWarn> | ||
| </PropertyGroup> | ||
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., build.proj))\src\Az.Post.props" /> | ||
| </Project> | ||
240 changes: 240 additions & 0 deletions
240
src/Billing/Billing.Management.Sdk/Generated/AddressOperations.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,240 @@ | ||
| // 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 System.Linq; | ||
| using Microsoft.Rest; | ||
| using Microsoft.Rest.Azure; | ||
| using Models; | ||
|
|
||
| /// <summary> | ||
| /// AddressOperations operations. | ||
| /// </summary> | ||
| internal partial class AddressOperations : Microsoft.Rest.IServiceOperations<BillingManagementClient>, IAddressOperations | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the AddressOperations class. | ||
| /// </summary> | ||
| /// <param name='client'> | ||
| /// Reference to the service client. | ||
| /// </param> | ||
| /// <exception cref="System.ArgumentNullException"> | ||
| /// Thrown when a required parameter is null | ||
| /// </exception> | ||
| internal AddressOperations (BillingManagementClient client) | ||
| { | ||
| if (client == null) | ||
| { | ||
| throw new System.ArgumentNullException("client"); | ||
| } | ||
| this.Client = client; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a reference to the BillingManagementClient | ||
| /// </summary> | ||
| public BillingManagementClient Client { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Validates an address. Use the operation to validate an address before using | ||
| /// it as soldTo or a billTo address. | ||
| /// </summary> | ||
| /// <param name='address'> | ||
| /// | ||
| /// </param> | ||
| /// <param name='customHeaders'> | ||
| /// Headers that will be added to request. | ||
| /// </param> | ||
| /// <param name='cancellationToken'> | ||
| /// The cancellation token. | ||
| /// </param> | ||
| /// <exception cref="Microsoft.Rest.Azure.CloudException"> | ||
| /// Thrown when the operation returned an invalid status code | ||
| /// </exception> | ||
| /// <exception cref="Microsoft.Rest.SerializationException"> | ||
| /// Thrown when unable to deserialize the response | ||
| /// </exception> | ||
| /// <exception cref="Microsoft.Rest.ValidationException"> | ||
| /// Thrown when a required parameter is null | ||
| /// </exception> | ||
| /// <exception cref="System.ArgumentNullException"> | ||
| /// Thrown when a required parameter is null | ||
| /// </exception> | ||
| /// <return> | ||
| /// A response object containing the response body and response headers. | ||
| /// </return> | ||
| public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<ValidateAddressResponse>> ValidateWithHttpMessagesAsync(AddressDetails address, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) | ||
| { | ||
|
|
||
|
|
||
|
|
||
|
|
||
| if (address == null) | ||
| { | ||
| throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "address"); | ||
| } | ||
| if (address != null) | ||
| { | ||
| address.Validate(); | ||
| } | ||
| string apiVersion = "2020-05-01"; | ||
| // Tracing | ||
| bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; | ||
| string _invocationId = null; | ||
| if (_shouldTrace) | ||
| { | ||
| _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); | ||
| System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>(); | ||
| tracingParameters.Add("apiVersion", apiVersion); | ||
|
|
||
| tracingParameters.Add("address", address); | ||
|
|
||
| tracingParameters.Add("cancellationToken", cancellationToken); | ||
| Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Validate", tracingParameters); | ||
| } | ||
| // Construct URL | ||
|
|
||
| var _baseUrl = this.Client.BaseUri.AbsoluteUri; | ||
| var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/validateAddress").ToString(); | ||
|
|
||
| System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>(); | ||
| if (apiVersion != null) | ||
| { | ||
| _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); | ||
| } | ||
| if (_queryParameters.Count > 0) | ||
| { | ||
| _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | ||
| } | ||
| // Create HTTP transport objects | ||
| var _httpRequest = new System.Net.Http.HttpRequestMessage(); | ||
| System.Net.Http.HttpResponseMessage _httpResponse = null; | ||
| _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); | ||
| _httpRequest.RequestUri = new System.Uri(_url); | ||
| // Set Headers | ||
| if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) | ||
| { | ||
| _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); | ||
| } | ||
| if (this.Client.AcceptLanguage != null) | ||
| { | ||
| if (_httpRequest.Headers.Contains("accept-language")) | ||
| { | ||
| _httpRequest.Headers.Remove("accept-language"); | ||
| } | ||
| _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.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 = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(address, this.Client.SerializationSettings); | ||
| _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); | ||
| _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); | ||
| } | ||
| // Set Credentials | ||
| if (this.Client.Credentials != null) | ||
| { | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
| await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| // Send Request | ||
| if (_shouldTrace) | ||
| { | ||
| Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | ||
| } | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
| _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | ||
| if (_shouldTrace) | ||
| { | ||
| Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | ||
| } | ||
|
|
||
| System.Net.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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_responseContent, this.Client.DeserializationSettings); | ||
| if (_errorBody != null) | ||
| { | ||
| ex.Body = _errorBody; | ||
| } | ||
| } | ||
| catch (Newtonsoft.Json.JsonException) | ||
| { | ||
| // Ignore the exception | ||
| } | ||
| ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); | ||
| ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); | ||
| if (_shouldTrace) | ||
| { | ||
| Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); | ||
| } | ||
| _httpRequest.Dispose(); | ||
| if (_httpResponse != null) | ||
| { | ||
| _httpResponse.Dispose(); | ||
| } | ||
| throw ex; | ||
| } | ||
| // Create Result | ||
| var _result = new Microsoft.Rest.Azure.AzureOperationResponse<ValidateAddressResponse>(); | ||
| _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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<ValidateAddressResponse>(_responseContent, this.Client.DeserializationSettings); | ||
| } | ||
| catch (Newtonsoft.Json.JsonException ex) | ||
| { | ||
| _httpRequest.Dispose(); | ||
| if (_httpResponse != null) | ||
| { | ||
| _httpResponse.Dispose(); | ||
| } | ||
| throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); | ||
| } | ||
| } | ||
| if (_shouldTrace) | ||
| { | ||
| Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); | ||
| } | ||
| return _result; | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/Billing/Billing.Management.Sdk/Generated/AddressOperationsExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // 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.Azure; | ||
| using Models; | ||
|
|
||
| /// <summary> | ||
| /// Extension methods for AddressOperations | ||
| /// </summary> | ||
| public static partial class AddressOperationsExtensions | ||
| { | ||
| /// <summary> | ||
| /// Validates an address. Use the operation to validate an address before using | ||
| /// it as soldTo or a billTo address. | ||
| /// </summary> | ||
| /// <param name='operations'> | ||
| /// The operations group for this extension method. | ||
| /// </param> | ||
| public static ValidateAddressResponse Validate(this IAddressOperations operations, AddressDetails address) | ||
| { | ||
| return ((IAddressOperations)operations).ValidateAsync(address).GetAwaiter().GetResult(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Validates an address. Use the operation to validate an address before using | ||
| /// it as soldTo or a billTo address. | ||
| /// </summary> | ||
| /// <param name='operations'> | ||
| /// The operations group for this extension method. | ||
| /// </param> | ||
| /// <param name='cancellationToken'> | ||
| /// The cancellation token. | ||
| /// </param> | ||
| public static async System.Threading.Tasks.Task<ValidateAddressResponse> ValidateAsync(this IAddressOperations operations, AddressDetails address, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) | ||
| { | ||
| using (var _result = await operations.ValidateWithHttpMessagesAsync(address, null, cancellationToken).ConfigureAwait(false)) | ||
| { | ||
| return _result.Body; | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.