Skip to content

Commit 2fa276a

Browse files
adxsdknetmentat9
authored andcommitted
.NET SDK Resource Provider:'Billing' (Azure#5682)
REST Spec PR 'Azure/azure-rest-api-specs#5546' REST Spec PR Author 'asarkar84' REST Spec PR Last commit
1 parent 213d06c commit 2fa276a

18 files changed

+1755
-322
lines changed

src/SDKs/Billing/Management.Billing/Generated/AgreementsOperations.cs

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for
4+
// license information.
5+
//
6+
// Code generated by Microsoft (R) AutoRest Code Generator.
7+
// Changes may cause incorrect behavior and will be lost if the code is
8+
// regenerated.
9+
// </auto-generated>
10+
11+
namespace Microsoft.Azure.Management.Billing
12+
{
13+
using Microsoft.Rest;
14+
using Microsoft.Rest.Azure;
15+
using Models;
16+
using System.Threading;
17+
using System.Threading.Tasks;
18+
19+
/// <summary>
20+
/// Extension methods for AgreementsOperations.
21+
/// </summary>
22+
public static partial class AgreementsOperationsExtensions
23+
{
24+
/// <summary>
25+
/// Lists all agreements for a billing account.
26+
/// </summary>
27+
/// <param name='operations'>
28+
/// The operations group for this extension method.
29+
/// </param>
30+
/// <param name='billingAccountName'>
31+
/// billing Account Id.
32+
/// </param>
33+
/// <param name='expand'>
34+
/// May be used to expand the participants.
35+
/// </param>
36+
public static AgreementListResult ListByBillingAccountName(this IAgreementsOperations operations, string billingAccountName, string expand = default(string))
37+
{
38+
return operations.ListByBillingAccountNameAsync(billingAccountName, expand).GetAwaiter().GetResult();
39+
}
40+
41+
/// <summary>
42+
/// Lists all agreements for a billing account.
43+
/// </summary>
44+
/// <param name='operations'>
45+
/// The operations group for this extension method.
46+
/// </param>
47+
/// <param name='billingAccountName'>
48+
/// billing Account Id.
49+
/// </param>
50+
/// <param name='expand'>
51+
/// May be used to expand the participants.
52+
/// </param>
53+
/// <param name='cancellationToken'>
54+
/// The cancellation token.
55+
/// </param>
56+
public static async Task<AgreementListResult> ListByBillingAccountNameAsync(this IAgreementsOperations operations, string billingAccountName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
57+
{
58+
using (var _result = await operations.ListByBillingAccountNameWithHttpMessagesAsync(billingAccountName, expand, null, cancellationToken).ConfigureAwait(false))
59+
{
60+
return _result.Body;
61+
}
62+
}
63+
64+
/// <summary>
65+
/// Get the agreement by name.
66+
/// </summary>
67+
/// <param name='operations'>
68+
/// The operations group for this extension method.
69+
/// </param>
70+
/// <param name='billingAccountName'>
71+
/// billing Account Id.
72+
/// </param>
73+
/// <param name='agreementName'>
74+
/// Agreement Id.
75+
/// </param>
76+
/// <param name='expand'>
77+
/// May be used to expand the participants.
78+
/// </param>
79+
public static Agreement Get(this IAgreementsOperations operations, string billingAccountName, string agreementName, string expand = default(string))
80+
{
81+
return operations.GetAsync(billingAccountName, agreementName, expand).GetAwaiter().GetResult();
82+
}
83+
84+
/// <summary>
85+
/// Get the agreement by name.
86+
/// </summary>
87+
/// <param name='operations'>
88+
/// The operations group for this extension method.
89+
/// </param>
90+
/// <param name='billingAccountName'>
91+
/// billing Account Id.
92+
/// </param>
93+
/// <param name='agreementName'>
94+
/// Agreement Id.
95+
/// </param>
96+
/// <param name='expand'>
97+
/// May be used to expand the participants.
98+
/// </param>
99+
/// <param name='cancellationToken'>
100+
/// The cancellation token.
101+
/// </param>
102+
public static async Task<Agreement> GetAsync(this IAgreementsOperations operations, string billingAccountName, string agreementName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken))
103+
{
104+
using (var _result = await operations.GetWithHttpMessagesAsync(billingAccountName, agreementName, expand, null, cancellationToken).ConfigureAwait(false))
105+
{
106+
return _result.Body;
107+
}
108+
}
109+
110+
}
111+
}

src/SDKs/Billing/Management.Billing/Generated/BillingManagementClient.cs

Lines changed: 18 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ public partial class BillingManagementClient : ServiceClient<BillingManagementCl
203203
/// </summary>
204204
public virtual ITransactionsByBillingAccountOperations TransactionsByBillingAccount { get; private set; }
205205

206+
/// <summary>
207+
/// Gets the ITransactionsByBillingProfileOperations.
208+
/// </summary>
209+
public virtual ITransactionsByBillingProfileOperations TransactionsByBillingProfile { get; private set; }
210+
211+
/// <summary>
212+
/// Gets the ITransactionsByInvoiceSectionOperations.
213+
/// </summary>
214+
public virtual ITransactionsByInvoiceSectionOperations TransactionsByInvoiceSection { get; private set; }
215+
206216
/// <summary>
207217
/// Gets the IPolicyOperations.
208218
/// </summary>
@@ -273,6 +283,11 @@ public partial class BillingManagementClient : ServiceClient<BillingManagementCl
273283
/// </summary>
274284
public virtual IBillingProfileBillingRoleAssignmentOperations BillingProfileBillingRoleAssignment { get; private set; }
275285

286+
/// <summary>
287+
/// Gets the IAgreementsOperations.
288+
/// </summary>
289+
public virtual IAgreementsOperations Agreements { get; private set; }
290+
276291
/// <summary>
277292
/// Initializes a new instance of the BillingManagementClient class.
278293
/// </summary>
@@ -539,6 +554,8 @@ private void Initialize()
539554
ProductsByInvoiceSection = new ProductsByInvoiceSectionOperations(this);
540555
Products = new ProductsOperations(this);
541556
TransactionsByBillingAccount = new TransactionsByBillingAccountOperations(this);
557+
TransactionsByBillingProfile = new TransactionsByBillingProfileOperations(this);
558+
TransactionsByInvoiceSection = new TransactionsByInvoiceSectionOperations(this);
542559
Policy = new PolicyOperations(this);
543560
BillingProperty = new BillingPropertyOperations(this);
544561
Transfers = new TransfersOperations(this);
@@ -553,6 +570,7 @@ private void Initialize()
553570
BillingAccountBillingRoleAssignment = new BillingAccountBillingRoleAssignmentOperations(this);
554571
InvoiceSectionBillingRoleAssignment = new InvoiceSectionBillingRoleAssignmentOperations(this);
555572
BillingProfileBillingRoleAssignment = new BillingProfileBillingRoleAssignmentOperations(this);
573+
Agreements = new AgreementsOperations(this);
556574
BaseUri = new System.Uri("https://management.azure.com");
557575
ApiVersion = "2018-11-01-preview";
558576
AcceptLanguage = "en-US";
@@ -588,229 +606,6 @@ private void Initialize()
588606
DeserializationSettings.Converters.Add(new TransformationJsonConverter());
589607
DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
590608
}
591-
/// <summary>
592-
/// Lists the transactions by billingProfileName for given start date and end
593-
/// date.
594-
/// <see href="https://docs.microsoft.com/en-us/rest/api/consumption/" />
595-
/// </summary>
596-
/// <param name='billingAccountName'>
597-
/// billing Account Id.
598-
/// </param>
599-
/// <param name='billingProfileName'>
600-
/// Billing Profile Id.
601-
/// </param>
602-
/// <param name='startDate'>
603-
/// Start date
604-
/// </param>
605-
/// <param name='endDate'>
606-
/// End date
607-
/// </param>
608-
/// <param name='filter'>
609-
/// May be used to filter by transaction kind. The filter supports 'eq', 'lt',
610-
/// 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or
611-
/// 'not'. Tag filter is a key value pair string where key and value is
612-
/// separated by a colon (:).
613-
/// </param>
614-
/// <param name='customHeaders'>
615-
/// Headers that will be added to request.
616-
/// </param>
617-
/// <param name='cancellationToken'>
618-
/// The cancellation token.
619-
/// </param>
620-
/// <exception cref="ErrorResponseException">
621-
/// Thrown when the operation returned an invalid status code
622-
/// </exception>
623-
/// <exception cref="SerializationException">
624-
/// Thrown when unable to deserialize the response
625-
/// </exception>
626-
/// <exception cref="ValidationException">
627-
/// Thrown when a required parameter is null
628-
/// </exception>
629-
/// <exception cref="System.ArgumentNullException">
630-
/// Thrown when a required parameter is null
631-
/// </exception>
632-
/// <return>
633-
/// A response object containing the response body and response headers.
634-
/// </return>
635-
public async Task<AzureOperationResponse<TransactionsListResult>> TransactionsByBillingProfileWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string startDate, string endDate, string filter = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
636-
{
637-
if (billingAccountName == null)
638-
{
639-
throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName");
640-
}
641-
if (billingProfileName == null)
642-
{
643-
throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName");
644-
}
645-
if (ApiVersion == null)
646-
{
647-
throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
648-
}
649-
if (startDate == null)
650-
{
651-
throw new ValidationException(ValidationRules.CannotBeNull, "startDate");
652-
}
653-
if (endDate == null)
654-
{
655-
throw new ValidationException(ValidationRules.CannotBeNull, "endDate");
656-
}
657-
// Tracing
658-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
659-
string _invocationId = null;
660-
if (_shouldTrace)
661-
{
662-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
663-
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
664-
tracingParameters.Add("billingAccountName", billingAccountName);
665-
tracingParameters.Add("billingProfileName", billingProfileName);
666-
tracingParameters.Add("startDate", startDate);
667-
tracingParameters.Add("endDate", endDate);
668-
tracingParameters.Add("filter", filter);
669-
tracingParameters.Add("cancellationToken", cancellationToken);
670-
ServiceClientTracing.Enter(_invocationId, this, "TransactionsByBillingProfile", tracingParameters);
671-
}
672-
// Construct URL
673-
var _baseUrl = BaseUri.AbsoluteUri;
674-
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/transactions").ToString();
675-
_url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName));
676-
_url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName));
677-
List<string> _queryParameters = new List<string>();
678-
if (ApiVersion != null)
679-
{
680-
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
681-
}
682-
if (startDate != null)
683-
{
684-
_queryParameters.Add(string.Format("startDate={0}", System.Uri.EscapeDataString(startDate)));
685-
}
686-
if (endDate != null)
687-
{
688-
_queryParameters.Add(string.Format("endDate={0}", System.Uri.EscapeDataString(endDate)));
689-
}
690-
if (filter != null)
691-
{
692-
_queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
693-
}
694-
if (_queryParameters.Count > 0)
695-
{
696-
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
697-
}
698-
// Create HTTP transport objects
699-
var _httpRequest = new HttpRequestMessage();
700-
HttpResponseMessage _httpResponse = null;
701-
_httpRequest.Method = new HttpMethod("GET");
702-
_httpRequest.RequestUri = new System.Uri(_url);
703-
// Set Headers
704-
if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
705-
{
706-
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
707-
}
708-
if (AcceptLanguage != null)
709-
{
710-
if (_httpRequest.Headers.Contains("accept-language"))
711-
{
712-
_httpRequest.Headers.Remove("accept-language");
713-
}
714-
_httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
715-
}
716-
717-
718-
if (customHeaders != null)
719-
{
720-
foreach(var _header in customHeaders)
721-
{
722-
if (_httpRequest.Headers.Contains(_header.Key))
723-
{
724-
_httpRequest.Headers.Remove(_header.Key);
725-
}
726-
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
727-
}
728-
}
729-
730-
// Serialize Request
731-
string _requestContent = null;
732-
// Set Credentials
733-
if (Credentials != null)
734-
{
735-
cancellationToken.ThrowIfCancellationRequested();
736-
await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
737-
}
738-
// Send Request
739-
if (_shouldTrace)
740-
{
741-
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
742-
}
743-
cancellationToken.ThrowIfCancellationRequested();
744-
_httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
745-
if (_shouldTrace)
746-
{
747-
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
748-
}
749-
HttpStatusCode _statusCode = _httpResponse.StatusCode;
750-
cancellationToken.ThrowIfCancellationRequested();
751-
string _responseContent = null;
752-
if ((int)_statusCode != 200)
753-
{
754-
var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
755-
try
756-
{
757-
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
758-
ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject<ErrorResponse>(_responseContent, DeserializationSettings);
759-
if (_errorBody != null)
760-
{
761-
ex.Body = _errorBody;
762-
}
763-
}
764-
catch (JsonException)
765-
{
766-
// Ignore the exception
767-
}
768-
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
769-
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
770-
if (_shouldTrace)
771-
{
772-
ServiceClientTracing.Error(_invocationId, ex);
773-
}
774-
_httpRequest.Dispose();
775-
if (_httpResponse != null)
776-
{
777-
_httpResponse.Dispose();
778-
}
779-
throw ex;
780-
}
781-
// Create Result
782-
var _result = new AzureOperationResponse<TransactionsListResult>();
783-
_result.Request = _httpRequest;
784-
_result.Response = _httpResponse;
785-
if (_httpResponse.Headers.Contains("x-ms-request-id"))
786-
{
787-
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
788-
}
789-
// Deserialize Response
790-
if ((int)_statusCode == 200)
791-
{
792-
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
793-
try
794-
{
795-
_result.Body = SafeJsonConvert.DeserializeObject<TransactionsListResult>(_responseContent, DeserializationSettings);
796-
}
797-
catch (JsonException ex)
798-
{
799-
_httpRequest.Dispose();
800-
if (_httpResponse != null)
801-
{
802-
_httpResponse.Dispose();
803-
}
804-
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
805-
}
806-
}
807-
if (_shouldTrace)
808-
{
809-
ServiceClientTracing.Exit(_invocationId, _result);
810-
}
811-
return _result;
812-
}
813-
814609
/// <summary>
815610
/// Cancel product by product id
816611
/// </summary>

0 commit comments

Comments
 (0)