diff --git a/src/ResourceManagement/Billing/Billing.Tests/Billing.Tests.xproj b/src/ResourceManagement/Billing/Billing.Tests/Billing.Tests.xproj
new file mode 100644
index 0000000000000..78e9abb2a3697
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/Billing.Tests.xproj
@@ -0,0 +1,21 @@
+
+
+
+ 14.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+ F4CDC178-3DBE-4535-A384-633AB0A802B9
+ Billing.Tests
+ .\obj
+ .\bin\
+
+
+ 2.0
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/Helpers/BillingManagementTestUtilities.cs b/src/ResourceManagement/Billing/Billing.Tests/Helpers/BillingManagementTestUtilities.cs
new file mode 100644
index 0000000000000..ace7c01bfffd3
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/Helpers/BillingManagementTestUtilities.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Microsoft.Azure.Management.Billing;
+using Microsoft.Azure.Test.HttpRecorder;
+using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
+using System;
+using System.Net;
+using System.Threading;
+
+namespace Billing.Tests.Helpers
+{
+ public static class BillingTestUtilities
+ {
+ public static BillingClient GetBillingManagementClient(MockContext context, RecordedDelegatingHandler handler = null)
+ {
+ if (handler != null)
+ {
+ handler.IsPassThrough = true;
+ }
+
+ var client = context.GetServiceClient(handlers:
+ handler ?? new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ return client;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/Helpers/RecordedDelegatingHandler.cs b/src/ResourceManagement/Billing/Billing.Tests/Helpers/RecordedDelegatingHandler.cs
new file mode 100644
index 0000000000000..cbd5e5ff96e90
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/Helpers/RecordedDelegatingHandler.cs
@@ -0,0 +1,92 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+
+namespace Billing.Tests.Helpers
+{
+ public class RecordedDelegatingHandler : DelegatingHandler
+ {
+ private HttpResponseMessage _response;
+
+ public RecordedDelegatingHandler()
+ {
+ StatusCodeToReturn = HttpStatusCode.Created;
+ SubsequentStatusCodeToReturn = StatusCodeToReturn;
+ }
+
+ public RecordedDelegatingHandler(HttpResponseMessage response)
+ {
+ StatusCodeToReturn = HttpStatusCode.Created;
+ SubsequentStatusCodeToReturn = StatusCodeToReturn;
+ _response = response;
+ }
+
+ public HttpStatusCode StatusCodeToReturn { get; set; }
+
+ public HttpStatusCode SubsequentStatusCodeToReturn { get; set; }
+
+ public string Request { get; private set; }
+
+ public HttpRequestHeaders RequestHeaders { get; private set; }
+
+ public HttpContentHeaders ContentHeaders { get; private set; }
+
+ public HttpMethod Method { get; private set; }
+
+ public Uri Uri { get; private set; }
+
+ public bool IsPassThrough { get; set; }
+
+ private int counter;
+
+ protected override async Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
+ {
+ counter++;
+ // Save request
+ if (request.Content == null)
+ {
+ Request = string.Empty;
+ }
+ else
+ {
+ Request = await request.Content.ReadAsStringAsync();
+ }
+ RequestHeaders = request.Headers;
+ if (request.Content != null)
+ {
+ ContentHeaders = request.Content.Headers;
+ }
+ Method = request.Method;
+ Uri = request.RequestUri;
+
+ // Prepare response
+ if (IsPassThrough)
+ {
+ return await base.SendAsync(request, cancellationToken);
+ }
+ else
+ {
+ if (_response != null && counter == 1)
+ {
+ return _response;
+ }
+ else
+ {
+ var statusCode = StatusCodeToReturn;
+ if (counter > 1)
+ {
+ statusCode = SubsequentStatusCodeToReturn;
+ }
+ HttpResponseMessage response = new HttpResponseMessage(statusCode);
+ response.Content = new StringContent("");
+ return response;
+ }
+ }
+ }
+ }
+}
diff --git a/src/ResourceManagement/Billing/Billing.Tests/Properties/AssemblyInfo.cs b/src/ResourceManagement/Billing/Billing.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000000..990a7806a2a6e
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Billing.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Billing.Tests")]
+[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/InvoicesTests.cs b/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/InvoicesTests.cs
new file mode 100644
index 0000000000000..b883949281d3d
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/InvoicesTests.cs
@@ -0,0 +1,100 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Billing.Tests.Helpers;
+using Microsoft.Azure.Management.Billing;
+using Microsoft.Azure.Management.Billing.Models;
+using Microsoft.Azure.Management.Resources;
+using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
+using System;
+using System.Linq;
+using System.Net;
+using Xunit;
+
+namespace Billing.Tests.ScenarioTests
+{
+ public class InvoicesTests : TestBase
+ {
+ const string DownloadUrlExpand = "downloadUrl";
+ const string RangeFilter = "invoicePeriodEndDate ge 2017-01-31 and invoicePeriodEndDate le 2017-02-28";
+ const string InvoiceName = "2017-02-09-117646100066812";
+
+ [Fact]
+ public void ListInvoicesTest()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ var invoices = billingMgmtClient.Invoices.List();
+ Assert.NotNull(invoices);
+ Assert.True(invoices.Any());
+ Assert.False(invoices.Any(x => x.DownloadUrl != null));
+ }
+ }
+
+ [Fact]
+ public void ListInvoicesWithQueryParametersTest()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ var invoices = billingMgmtClient.Invoices.List(DownloadUrlExpand, RangeFilter, null, 1);
+ Assert.NotNull(invoices);
+ Assert.Equal(1, invoices.Count());
+ Assert.NotNull(invoices.First().DownloadUrl);
+ var invoice = invoices.First();
+ Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
+ Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
+ }
+ }
+
+ [Fact]
+ public void GetLatestInvoice()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ var invoice = billingMgmtClient.Invoices.GetLatest();
+ Assert.NotNull(invoice);
+ Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
+ Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
+ }
+ }
+
+ [Fact]
+ public void GetInvoiceWithName()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ var invoice = billingMgmtClient.Invoices.Get(InvoiceName);
+ Assert.NotNull(invoice);
+ Assert.Equal(InvoiceName, invoice.Name);
+ Assert.False(string.IsNullOrWhiteSpace(invoice.DownloadUrl.Url));
+ Assert.True(invoice.DownloadUrl.ExpiryTime.HasValue);
+ }
+ }
+
+ [Fact]
+ public void GetInvoicesNoResult()
+ {
+ string rangeFilter = "invoicePeriodEndDate lt 2016-01-31";
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ try
+ {
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+ billingMgmtClient.Invoices.List(DownloadUrlExpand, rangeFilter, null, 1);
+ Assert.False(true, "ErrorResponseException should have been thrown");
+ }
+ catch(ErrorResponseException e)
+ {
+ Assert.NotNull(e.Body);
+ Assert.NotNull(e.Body.Error);
+ Assert.Equal("ResourceNotFound", e.Body.Error.Code);
+ Assert.False(string.IsNullOrWhiteSpace(e.Body.Error.Message));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/OperationsTest.cs b/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/OperationsTest.cs
new file mode 100644
index 0000000000000..56329b87e3d1e
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/ScenarioTests/OperationsTest.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Billing.Tests.Helpers;
+using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
+using System.Linq;
+using System.Net;
+using Xunit;
+using Microsoft.Azure.Management.Billing;
+
+namespace Billing.Tests.ScenarioTests
+{
+ public class OperationsTests : TestBase
+ {
+ [Fact]
+ public void ListOperationsTest()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ // Create client
+ var billingMgmtClient = BillingTestUtilities.GetBillingManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ // Get operations
+ var operations = billingMgmtClient.Operations.List();
+
+ // Verify operations are returned
+ Assert.NotNull(operations);
+ Assert.True(operations.Any());
+ }
+ }
+ }
+}
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoiceWithName.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoiceWithName.json
new file mode 100644
index 0000000000000..5c2d2e99b7589
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoiceWithName.json
@@ -0,0 +1,75 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/2017-02-09-117646100066812?api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDM0N2Q2M2EtNDIxYS00M2E3LTgzNmEtNWYzODljNzljZDA3L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9pbnZvaWNlcy8yMDE3LTAyLTA5LTExNzY0NjEwMDA2NjgxMj9hcGktdmVyc2lvbj0yMDE3LTAyLTI3LXByZXZpZXc=",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "85f70922-65cc-4047-bb92-6b413ed8d44d"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/2017-02-09-117646100066812\",\r\n \"type\": \"Microsoft.Billing/invoices\",\r\n \"name\": \"2017-02-09-117646100066812\",\r\n \"properties\": {\r\n \"downloadUrl\": {\r\n \"expiryTime\": \"2017-02-18T20:44:40Z\",\r\n \"url\": \"https://billinsstorev2test.blob.core.windows.net/invoices/0347d63a-421a-43a7-836a-5f389c79cd07-2017-02-09-117646100066812.pdf?sv=2014-02-14&sr=b&sig=AJW5hhGYlN3DD3%2FL%2B11N0Y40CnGf2B46ff4LXqiG5ds%3D&se=2017-02-18T20%3A44%3A40Z&sp=r\"\r\n },\r\n \"invoicePeriodEndDate\": \"2017-02-09\",\r\n \"invoicePeriodStartDate\": \"2017-01-10\"\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:42 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-subscription-reads": [
+ "14998"
+ ],
+ "x-ms-request-id": [
+ "d4b80d41-3aad-4354-8a08-d2082eeb0e64"
+ ],
+ "x-ms-correlation-request-id": [
+ "d4b80d41-3aad-4354-8a08-d2082eeb0e64"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194442Z:d4b80d41-3aad-4354-8a08-d2082eeb0e64"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoicesNoResult.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoicesNoResult.json
new file mode 100644
index 0000000000000..19c43dfef7229
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetInvoicesNoResult.json
@@ -0,0 +1,72 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices?$expand=downloadUrl&$filter=invoicePeriodEndDate%20lt%202016-01-31&$top=1&api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDM0N2Q2M2EtNDIxYS00M2E3LTgzNmEtNWYzODljNzljZDA3L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9pbnZvaWNlcz8kZXhwYW5kPWRvd25sb2FkVXJsJiRmaWx0ZXI9aW52b2ljZVBlcmlvZEVuZERhdGUlMjBsdCUyMDIwMTYtMDEtMzEmJHRvcD0xJmFwaS12ZXJzaW9uPTIwMTctMDItMjctcHJldmlldw==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "88ecaa48-34bf-4889-8522-c89e405d7fc9"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"ResourceNotFound\",\r\n \"target\": \"https://billing-preview.windowsazure.com/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices?$expand=downloadUrl&$filter=invoicePeriodEndDate%20lt%202016-01-31&$top=1&api-version=2017-02-27-preview\",\r\n \"message\": \"Could not find invoice for the subscription.\"\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Length": [
+ "339"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:02 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-subscription-reads": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "a3ca3620-41a5-4f1f-9928-22d3e933f67d"
+ ],
+ "x-ms-correlation-request-id": [
+ "a3ca3620-41a5-4f1f-9928-22d3e933f67d"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194402Z:a3ca3620-41a5-4f1f-9928-22d3e933f67d"
+ ]
+ },
+ "StatusCode": 404
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetLatestInvoice.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetLatestInvoice.json
new file mode 100644
index 0000000000000..f62420df072ac
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/GetLatestInvoice.json
@@ -0,0 +1,75 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/latest?api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDM0N2Q2M2EtNDIxYS00M2E3LTgzNmEtNWYzODljNzljZDA3L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9pbnZvaWNlcy9sYXRlc3Q/YXBpLXZlcnNpb249MjAxNy0wMi0yNy1wcmV2aWV3",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "f71ea687-4e8b-445c-8143-ea7522a06ee2"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/2017-02-09-117646100066812\",\r\n \"type\": \"Microsoft.Billing/invoices\",\r\n \"name\": \"2017-02-09-117646100066812\",\r\n \"properties\": {\r\n \"downloadUrl\": {\r\n \"expiryTime\": \"2017-02-18T20:44:31Z\",\r\n \"url\": \"https://billinsstorev2test.blob.core.windows.net/invoices/0347d63a-421a-43a7-836a-5f389c79cd07-2017-02-09-117646100066812.pdf?sv=2014-02-14&sr=b&sig=VHv8ac7F2mYHl2AfTe6QxZX0OKh8C7yEDtny2Gl4rpE%3D&se=2017-02-18T20%3A44%3A31Z&sp=r\"\r\n },\r\n \"invoicePeriodEndDate\": \"2017-02-09\",\r\n \"invoicePeriodStartDate\": \"2017-01-10\"\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:33 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-subscription-reads": [
+ "14998"
+ ],
+ "x-ms-request-id": [
+ "d3c5e352-ca1a-4416-bff3-6af20df7ee54"
+ ],
+ "x-ms-correlation-request-id": [
+ "d3c5e352-ca1a-4416-bff3-6af20df7ee54"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194433Z:d3c5e352-ca1a-4416-bff3-6af20df7ee54"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesTest.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesTest.json
new file mode 100644
index 0000000000000..b1645b5d9ac16
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesTest.json
@@ -0,0 +1,75 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices?api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDM0N2Q2M2EtNDIxYS00M2E3LTgzNmEtNWYzODljNzljZDA3L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9pbnZvaWNlcz9hcGktdmVyc2lvbj0yMDE3LTAyLTI3LXByZXZpZXc=",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "cdd6a8cf-834d-47d9-8347-7d2cb4197ff5"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/2017-02-09-117646100066812\",\r\n \"type\": \"Microsoft.Billing/invoices\",\r\n \"name\": \"2017-02-09-117646100066812\",\r\n \"properties\": {\r\n \"invoicePeriodEndDate\": \"2017-02-09\",\r\n \"invoicePeriodStartDate\": \"2017-01-10\"\r\n }\r\n }\r\n ]\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:12 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-subscription-reads": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "b863b387-0c12-4e3a-a6db-ccba657e2a9b"
+ ],
+ "x-ms-correlation-request-id": [
+ "b863b387-0c12-4e3a-a6db-ccba657e2a9b"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194412Z:b863b387-0c12-4e3a-a6db-ccba657e2a9b"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesWithQueryParametersTest.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesWithQueryParametersTest.json
new file mode 100644
index 0000000000000..03aa775769b05
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.InvoicesTests/ListInvoicesWithQueryParametersTest.json
@@ -0,0 +1,75 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices?$expand=downloadUrl&$filter=invoicePeriodEndDate%20ge%202017-01-31%20and%20invoicePeriodEndDate%20le%202017-02-28&$top=1&api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDM0N2Q2M2EtNDIxYS00M2E3LTgzNmEtNWYzODljNzljZDA3L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9pbnZvaWNlcz8kZXhwYW5kPWRvd25sb2FkVXJsJiRmaWx0ZXI9aW52b2ljZVBlcmlvZEVuZERhdGUlMjBnZSUyMDIwMTctMDEtMzElMjBhbmQlMjBpbnZvaWNlUGVyaW9kRW5kRGF0ZSUyMGxlJTIwMjAxNy0wMi0yOCYkdG9wPTEmYXBpLXZlcnNpb249MjAxNy0wMi0yNy1wcmV2aWV3",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "68e7d911-f619-43a1-ad04-5ef27f1bd321"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/0347d63a-421a-43a7-836a-5f389c79cd07/providers/Microsoft.Billing/invoices/2017-02-09-117646100066812\",\r\n \"type\": \"Microsoft.Billing/invoices\",\r\n \"name\": \"2017-02-09-117646100066812\",\r\n \"properties\": {\r\n \"downloadUrl\": {\r\n \"expiryTime\": \"2017-02-18T20:44:23Z\",\r\n \"url\": \"https://billinsstorev2test.blob.core.windows.net/invoices/0347d63a-421a-43a7-836a-5f389c79cd07-2017-02-09-117646100066812.pdf?sv=2014-02-14&sr=b&sig=eVlG3xRv4HiT5ygDxCTw2N4b3p2OyZABIHRIj22Oa5Y%3D&se=2017-02-18T20%3A44%3A23Z&sp=r\"\r\n },\r\n \"invoicePeriodEndDate\": \"2017-02-09\",\r\n \"invoicePeriodStartDate\": \"2017-01-10\"\r\n }\r\n }\r\n ]\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:24 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-subscription-reads": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "8c7f108e-3351-4848-85d4-91a434b2b149"
+ ],
+ "x-ms-correlation-request-id": [
+ "8c7f108e-3351-4848-85d4-91a434b2b149"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194425Z:8c7f108e-3351-4848-85d4-91a434b2b149"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.OperationsTests/ListOperationsTest.json b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.OperationsTests/ListOperationsTest.json
new file mode 100644
index 0000000000000..0296925abce98
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/SessionRecords/Billing.Tests.ScenarioTests.OperationsTests/ListOperationsTest.json
@@ -0,0 +1,75 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Billing/operations?api-version=2017-02-27-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9vcGVyYXRpb25zP2FwaS12ZXJzaW9uPTIwMTctMDItMjctcHJldmlldw==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "47fad9df-5cde-4850-92fd-d743645bbae2"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.24410.01",
+ "Microsoft.Azure.Management.Billing.BillingClient/1.0.0-preview"
+ ]
+ },
+ "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"Microsoft.Billing/invoices/read\",\r\n \"display\": {\r\n \"provider\": \"Microsoft Billing\",\r\n \"resource\": \"Invoices\",\r\n \"operation\": \"Get Invoice\",\r\n \"description\": \"Gets list of available invoices.\"\r\n }\r\n }\r\n ]\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Sat, 18 Feb 2017 19:44:43 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "499f74eb-2de1-464d-925f-535b4d985981"
+ ],
+ "x-ms-correlation-request-id": [
+ "499f74eb-2de1-464d-925f-535b4d985981"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20170218T194443Z:499f74eb-2de1-464d-925f-535b4d985981"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "0347d63a-421a-43a7-836a-5f389c79cd07"
+ }
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.Tests/project.json b/src/ResourceManagement/Billing/Billing.Tests/project.json
new file mode 100644
index 0000000000000..3f9b26cf836d5
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.Tests/project.json
@@ -0,0 +1,43 @@
+{
+ "version": "1.0.0-*",
+ "description": "Billing.Tests Class Library",
+ "authors": [ "Microsoft Corporation" ],
+
+ "packOptions": {
+ "summary": "Billing.Tests Tests.",
+ "tags": [ "" ],
+ "projectUrl": "https://github.com/Azure/azure-sdk-for-net",
+ "licenseUrl": "https://raw.githubusercontent.com/Microsoft/dotnet/master/LICENSE",
+ },
+ "buildOptions": {
+ "delaySign": true,
+ "publicSign": false,
+ "keyFile": "../../../../tools/MSSharedLibKey.snk",
+ "compile": "../../../../tools/DisableTestRunParallel.cs"
+ },
+
+ "testRunner": "xunit",
+ "frameworks": {
+ "netcoreapp1.0": {
+ "imports": ["dnxcore50", "portable-net45+win8"],
+ "dependencies": {
+ }
+ }
+ },
+ "dependencies": {
+ "Microsoft.NETCore.App": {
+ "type": "platform",
+ "version": "1.0.0"
+ },
+ "Microsoft.Azure.Management.Billing": {
+ "target": "project",
+ "type": "build"
+ },
+ "Microsoft.Azure.Test.HttpRecorder": "[1.6.7-preview,2.0.0)",
+ "Microsoft.Rest.ClientRuntime.Azure.TestFramework": "[1.5.1-preview,2.0.0)",
+ "Microsoft.Rest.ClientRuntime.Azure": "[3.3.4,4.0.0)",
+ "Microsoft.Azure.ResourceManager": "1.0.0-preview",
+ "xunit": "2.2.0-beta2-build3300",
+ "dotnet-test-xunit": "2.2.0-preview2-build1029"
+ },
+}
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Billing.sln b/src/ResourceManagement/Billing/Billing.sln
new file mode 100644
index 0000000000000..67d459e826c50
--- /dev/null
+++ b/src/ResourceManagement/Billing/Billing.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Management.Billing", "Microsoft.Azure.Management.Billing\Microsoft.Azure.Management.Billing.xproj", "{1370136C-378A-46ED-9D4E-DB5A925709D4}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Billing.Tests", "Billing.Tests\Billing.Tests.xproj", "{F4CDC178-3DBE-4535-A384-633AB0A802B9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1370136C-378A-46ED-9D4E-DB5A925709D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1370136C-378A-46ED-9D4E-DB5A925709D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1370136C-378A-46ED-9D4E-DB5A925709D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1370136C-378A-46ED-9D4E-DB5A925709D4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F4CDC178-3DBE-4535-A384-633AB0A802B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F4CDC178-3DBE-4535-A384-633AB0A802B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F4CDC178-3DBE-4535-A384-633AB0A802B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F4CDC178-3DBE-4535-A384-633AB0A802B9}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/BillingClient.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/BillingClient.cs
new file mode 100644
index 0000000000000..089c9dc7e316c
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/BillingClient.cs
@@ -0,0 +1,330 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+
+ ///
+ /// Billing client provides access to billing resources for Azure
+ /// Web-Direct subscriptions. Other subscription types which were not
+ /// purchased directly through the Azure web portal are not supported
+ /// through this preview API.
+ ///
+ public partial class BillingClient : ServiceClient, IBillingClient, IAzureClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ public System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ public ServiceClientCredentials Credentials { get; private set; }
+
+ ///
+ /// Version of the API to be used with the client request. The current version
+ /// is 2017-02-27-preview.
+ ///
+ public string ApiVersion { get; private set; }
+
+ ///
+ /// Azure Subscription ID.
+ ///
+ public string SubscriptionId { get; set; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running Operations.
+ /// Default value is 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// When set to true a unique x-ms-client-request-id value is generated and
+ /// included in each request. Default is true.
+ ///
+ public bool? GenerateClientRequestId { get; set; }
+
+ ///
+ /// Gets the IInvoicesOperations.
+ ///
+ public virtual IInvoicesOperations Invoices { get; private set; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ public virtual IOperations Operations { get; private set; }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected BillingClient(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected BillingClient(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected BillingClient(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected BillingClient(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public BillingClient(ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public BillingClient(ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public BillingClient(System.Uri baseUri, ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the BillingClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public BillingClient(System.Uri baseUri, ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ Invoices = new InvoicesOperations(this);
+ Operations = new Operations(this);
+ BaseUri = new System.Uri("https://management.azure.com");
+ ApiVersion = "2017-02-27-preview";
+ AcceptLanguage = "en-US";
+ LongRunningOperationRetryTimeout = 30;
+ GenerateClientRequestId = true;
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Formatting.Indented,
+ DateFormatHandling = DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = DateTimeZoneHandling.Utc,
+ NullValueHandling = NullValueHandling.Ignore,
+ ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ SerializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = DateTimeZoneHandling.Utc,
+ NullValueHandling = NullValueHandling.Ignore,
+ ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ DeserializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
+ }
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IBillingClient.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IBillingClient.cs
new file mode 100644
index 0000000000000..1f4e2c59db139
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IBillingClient.cs
@@ -0,0 +1,87 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ /// Billing client provides access to billing resources for Azure
+ /// Web-Direct subscriptions. Other subscription types which were not
+ /// purchased directly through the Azure web portal are not supported
+ /// through this preview API.
+ ///
+ public partial interface IBillingClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ ServiceClientCredentials Credentials { get; }
+
+ ///
+ /// Version of the API to be used with the client request. The current
+ /// version is 2017-02-27-preview.
+ ///
+ string ApiVersion { get; }
+
+ ///
+ /// Azure Subscription ID.
+ ///
+ string SubscriptionId { get; set; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running
+ /// Operations. Default value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// When set to true a unique x-ms-client-request-id value is generated
+ /// and included in each request. Default is true.
+ ///
+ bool? GenerateClientRequestId { get; set; }
+
+
+ ///
+ /// Gets the IInvoicesOperations.
+ ///
+ IInvoicesOperations Invoices { get; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ IOperations Operations { get; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IInvoicesOperations.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IInvoicesOperations.cs
new file mode 100644
index 0000000000000..a36fd8dd09e51
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IInvoicesOperations.cs
@@ -0,0 +1,141 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// InvoicesOperations operations.
+ ///
+ public partial interface IInvoicesOperations
+ {
+ ///
+ /// Lists the available invoices for a subscription in reverse
+ /// chronological order beginning with the most recent invoice. In
+ /// preview, invoices are available via this API only for invoice
+ /// periods which end December 1, 2016 or later
+ ///
+ ///
+ ///
+ /// May be used to expand the downloadUrl property within a list of
+ /// invoices. This enables download links to be generated for multiple
+ /// invoices at once. By default, downloadURLs are not included when
+ /// listing invoices.
+ ///
+ ///
+ /// May be used to filter invoices by invoicePeriodEndDate. The filter
+ /// supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not
+ /// currently support 'ne', 'or', or 'not'
+ ///
+ ///
+ /// Skiptoken is only used if a previous operation returned a partial
+ /// result. If a previous response contains a nextLink element, the
+ /// value of the nextLink element will include a skiptoken parameter
+ /// that specifies a starting point to use for subsequent calls.
+ ///
+ ///
+ /// May be used to limit the number of results to the most recent N
+ /// invoices.
+ ///
+ ///
+ /// 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>> ListWithHttpMessagesAsync(string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Gets a named invoice resource. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The name of an invoice resource.
+ ///
+ ///
+ /// 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> GetWithHttpMessagesAsync(string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Gets the most recent invoice. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// 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> GetLatestWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Lists the available invoices for a subscription in reverse
+ /// chronological order beginning with the most recent invoice. In
+ /// preview, invoices are available via this API only for invoice
+ /// periods which end December 1, 2016 or later
+ ///
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IOperations.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IOperations.cs
new file mode 100644
index 0000000000000..42e76ab40aa9c
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/IOperations.cs
@@ -0,0 +1,69 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Operations operations.
+ ///
+ public partial interface IOperations
+ {
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// 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>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperations.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperations.cs
new file mode 100644
index 0000000000000..7c65b78a187aa
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperations.cs
@@ -0,0 +1,808 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using 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;
+
+ ///
+ /// InvoicesOperations operations.
+ ///
+ internal partial class InvoicesOperations : IServiceOperations, IInvoicesOperations
+ {
+ ///
+ /// Initializes a new instance of the InvoicesOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal InvoicesOperations(BillingClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingClient
+ ///
+ public BillingClient Client { get; private set; }
+
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// May be used to expand the downloadUrl property within a list of invoices.
+ /// This enables download links to be generated for multiple invoices at once.
+ /// By default, downloadURLs are not included when listing invoices.
+ ///
+ ///
+ /// May be used to filter invoices by invoicePeriodEndDate. The filter supports
+ /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support
+ /// 'ne', 'or', or 'not'
+ ///
+ ///
+ /// Skiptoken is only used if a previous operation returned a partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a skiptoken parameter that specifies a
+ /// starting point to use for subsequent calls.
+ ///
+ ///
+ /// May be used to limit the number of results to the most recent N invoices.
+ ///
+ ///
+ /// 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>> ListWithHttpMessagesAsync(string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ if (top > 100)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 100);
+ }
+ if (top < 1)
+ {
+ throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1);
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("expand", expand);
+ tracingParameters.Add("filter", filter);
+ tracingParameters.Add("skiptoken", skiptoken);
+ tracingParameters.Add("top", top);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices").ToString();
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ List _queryParameters = new List();
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ if (filter != null)
+ {
+ _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
+ }
+ if (skiptoken != null)
+ {
+ _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken)));
+ }
+ if (top != null)
+ {
+ _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
+ }
+ 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 System.Net.Http.HttpRequestMessage();
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new System.Net.Http.HttpMethod("GET");
+ _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;
+ // 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;
+ }
+
+ ///
+ /// Gets a named invoice resource. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The name of an invoice resource.
+ ///
+ ///
+ /// 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> GetWithHttpMessagesAsync(string invoiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ if (invoiceName == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "invoiceName");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("invoiceName", invoiceName);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}").ToString();
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ _url = _url.Replace("{invoiceName}", System.Uri.EscapeDataString(invoiceName));
+ 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 System.Net.Http.HttpRequestMessage();
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new System.Net.Http.HttpMethod("GET");
+ _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;
+ // 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;
+ }
+
+ ///
+ /// Gets the most recent invoice. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// 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> GetLatestWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.SubscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetLatest", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/latest").ToString();
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
+ 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 System.Net.Http.HttpRequestMessage();
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new System.Net.Http.HttpMethod("GET");
+ _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;
+ // 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;
+ }
+
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ 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("GET");
+ _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;
+ // 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/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperationsExtensions.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperationsExtensions.cs
new file mode 100644
index 0000000000000..2de2a232e0627
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/InvoicesOperationsExtensions.cs
@@ -0,0 +1,208 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for InvoicesOperations.
+ ///
+ public static partial class InvoicesOperationsExtensions
+ {
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the downloadUrl property within a list of invoices.
+ /// This enables download links to be generated for multiple invoices at once.
+ /// By default, downloadURLs are not included when listing invoices.
+ ///
+ ///
+ /// May be used to filter invoices by invoicePeriodEndDate. The filter supports
+ /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support
+ /// 'ne', 'or', or 'not'
+ ///
+ ///
+ /// Skiptoken is only used if a previous operation returned a partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a skiptoken parameter that specifies a
+ /// starting point to use for subsequent calls.
+ ///
+ ///
+ /// May be used to limit the number of results to the most recent N invoices.
+ ///
+ public static IPage List(this IInvoicesOperations operations, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?))
+ {
+ return operations.ListAsync(expand, filter, skiptoken, top).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// May be used to expand the downloadUrl property within a list of invoices.
+ /// This enables download links to be generated for multiple invoices at once.
+ /// By default, downloadURLs are not included when listing invoices.
+ ///
+ ///
+ /// May be used to filter invoices by invoicePeriodEndDate. The filter supports
+ /// 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support
+ /// 'ne', 'or', or 'not'
+ ///
+ ///
+ /// Skiptoken is only used if a previous operation returned a partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a skiptoken parameter that specifies a
+ /// starting point to use for subsequent calls.
+ ///
+ ///
+ /// May be used to limit the number of results to the most recent N invoices.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IInvoicesOperations operations, string expand = default(string), string filter = default(string), string skiptoken = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(expand, filter, skiptoken, top, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a named invoice resource. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of an invoice resource.
+ ///
+ public static Invoice Get(this IInvoicesOperations operations, string invoiceName)
+ {
+ return operations.GetAsync(invoiceName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets a named invoice resource. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of an invoice resource.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IInvoicesOperations operations, string invoiceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(invoiceName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets the most recent invoice. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ public static Invoice GetLatest(this IInvoicesOperations operations)
+ {
+ return operations.GetLatestAsync().GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets the most recent invoice. When getting a single invoice, the
+ /// downloadUrl property is expanded automatically.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetLatestAsync(this IInvoicesOperations operations, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetLatestWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListNext(this IInvoicesOperations operations, string nextPageLink)
+ {
+ return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists the available invoices for a subscription in reverse chronological
+ /// order beginning with the most recent invoice. In preview, invoices are
+ /// available via this API only for invoice periods which end December 1, 2016
+ /// or later
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListNextAsync(this IInvoicesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/DownloadUrl.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/DownloadUrl.cs
new file mode 100644
index 0000000000000..ffb89823a9a96
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/DownloadUrl.cs
@@ -0,0 +1,54 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// A secure URL that can be used to download a PDF invoice until the URL
+ /// expires.
+ ///
+ public partial class DownloadUrl
+ {
+ ///
+ /// Initializes a new instance of the DownloadUrl class.
+ ///
+ public DownloadUrl() { }
+
+ ///
+ /// Initializes a new instance of the DownloadUrl class.
+ ///
+ /// The time in UTC at which this download URL
+ /// will expire.
+ /// The URL to the PDF file.
+ public DownloadUrl(System.DateTime? expiryTime = default(System.DateTime?), string url = default(string))
+ {
+ ExpiryTime = expiryTime;
+ Url = url;
+ }
+
+ ///
+ /// Gets the time in UTC at which this download URL will expire.
+ ///
+ [JsonProperty(PropertyName = "expiryTime")]
+ public System.DateTime? ExpiryTime { get; protected set; }
+
+ ///
+ /// Gets the URL to the PDF file.
+ ///
+ [JsonProperty(PropertyName = "url")]
+ public string Url { get; protected set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorDetails.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorDetails.cs
new file mode 100644
index 0000000000000..f0656c91eec5b
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorDetails.cs
@@ -0,0 +1,61 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The details of the error.
+ ///
+ public partial class ErrorDetails
+ {
+ ///
+ /// Initializes a new instance of the ErrorDetails class.
+ ///
+ public ErrorDetails() { }
+
+ ///
+ /// Initializes a new instance of the ErrorDetails class.
+ ///
+ /// Error code.
+ /// Error message indicating why the operation
+ /// failed.
+ /// The target of the particular error.
+ public ErrorDetails(string code = default(string), string message = default(string), string target = default(string))
+ {
+ Code = code;
+ Message = message;
+ Target = target;
+ }
+
+ ///
+ /// Gets error code.
+ ///
+ [JsonProperty(PropertyName = "code")]
+ public string Code { get; protected set; }
+
+ ///
+ /// Gets error message indicating why the operation failed.
+ ///
+ [JsonProperty(PropertyName = "message")]
+ public string Message { get; protected set; }
+
+ ///
+ /// Gets the target of the particular error.
+ ///
+ [JsonProperty(PropertyName = "target")]
+ public string Target { get; protected set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponse.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponse.cs
new file mode 100644
index 0000000000000..1752c28c63928
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponse.cs
@@ -0,0 +1,43 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Error response indicates that the service is not able to process the
+ /// incoming request. The reason is provided in the error message.
+ ///
+ public partial class ErrorResponse
+ {
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ public ErrorResponse() { }
+
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ public ErrorResponse(ErrorDetails error = default(ErrorDetails))
+ {
+ Error = error;
+ }
+
+ ///
+ ///
+ [JsonProperty(PropertyName = "error")]
+ public ErrorDetails Error { get; set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponseException.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponseException.cs
new file mode 100644
index 0000000000000..421682de6e2fd
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/ErrorResponseException.cs
@@ -0,0 +1,104 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Rest;
+ using System.Runtime;
+ using System.Runtime.Serialization;
+ using System.Security;
+
+ ///
+ /// Exception thrown for an invalid response with ErrorResponse
+ /// information.
+ ///
+#if !PORTABLE
+ [System.Serializable]
+#endif
+ public class ErrorResponseException : RestException
+ {
+ ///
+ /// Gets information about the associated HTTP request.
+ ///
+ public HttpRequestMessageWrapper Request { get; set; }
+
+ ///
+ /// Gets information about the associated HTTP response.
+ ///
+ public HttpResponseMessageWrapper Response { get; set; }
+
+ ///
+ /// Gets or sets the body object.
+ ///
+ public ErrorResponse Body { get; set; }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ public ErrorResponseException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ public ErrorResponseException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ /// Inner exception.
+ public ErrorResponseException(string message, System.Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+#if !PORTABLE
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// Serialization info.
+ /// Streaming context.
+ protected ErrorResponseException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
+
+ ///
+ /// Serializes content of the exception.
+ ///
+ /// Serialization info.
+ /// Streaming context.
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)]
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ if (info == null)
+ {
+ throw new System.ArgumentNullException("info");
+ }
+
+ info.AddValue("Request", Request);
+ info.AddValue("Response", Response);
+ info.AddValue("Body", Body);
+ }
+#endif
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Invoice.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Invoice.cs
new file mode 100644
index 0000000000000..c70148ab35cff
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Invoice.cs
@@ -0,0 +1,75 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Rest;
+ using Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// An invoice resource can be used download a PDF version of an invoice.
+ ///
+ [JsonTransformation]
+ public partial class Invoice : Resource
+ {
+ ///
+ /// Initializes a new instance of the Invoice class.
+ ///
+ public Invoice() { }
+
+ ///
+ /// Initializes a new instance of the Invoice class.
+ ///
+ /// Resource Id
+ /// Resource name
+ /// Resource type
+ /// The start of the date range
+ /// covered by the invoice.
+ /// The end of the date range
+ /// covered by the invoice.
+ /// A secure link to download the PDF version
+ /// of an invoice. The link will cease to work after its expiry time is
+ /// reached.
+ public Invoice(string id = default(string), string name = default(string), string type = default(string), System.DateTime? invoicePeriodStartDate = default(System.DateTime?), System.DateTime? invoicePeriodEndDate = default(System.DateTime?), DownloadUrl downloadUrl = default(DownloadUrl))
+ : base(id, name, type)
+ {
+ InvoicePeriodStartDate = invoicePeriodStartDate;
+ InvoicePeriodEndDate = invoicePeriodEndDate;
+ DownloadUrl = downloadUrl;
+ }
+
+ ///
+ /// Gets the start of the date range covered by the invoice.
+ ///
+ [JsonConverter(typeof(DateJsonConverter))]
+ [JsonProperty(PropertyName = "properties.invoicePeriodStartDate")]
+ public System.DateTime? InvoicePeriodStartDate { get; protected set; }
+
+ ///
+ /// Gets the end of the date range covered by the invoice.
+ ///
+ [JsonConverter(typeof(DateJsonConverter))]
+ [JsonProperty(PropertyName = "properties.invoicePeriodEndDate")]
+ public System.DateTime? InvoicePeriodEndDate { get; protected set; }
+
+ ///
+ /// Gets or sets a secure link to download the PDF version of an
+ /// invoice. The link will cease to work after its expiry time is
+ /// reached.
+ ///
+ [JsonProperty(PropertyName = "properties.downloadUrl")]
+ public DownloadUrl DownloadUrl { get; set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Operation.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Operation.cs
new file mode 100644
index 0000000000000..00f35ccd9bae9
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Operation.cs
@@ -0,0 +1,54 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// A Billing REST API operation
+ ///
+ public partial class Operation
+ {
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ public Operation() { }
+
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ /// Operation name:
+ /// {provider}/{resource}/{operation}
+ /// The object that represents the
+ /// operation.
+ public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay))
+ {
+ Name = name;
+ Display = display;
+ }
+
+ ///
+ /// Gets operation name: {provider}/{resource}/{operation}
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; protected set; }
+
+ ///
+ /// Gets or sets the object that represents the operation.
+ ///
+ [JsonProperty(PropertyName = "display")]
+ public OperationDisplay Display { get; set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/OperationDisplay.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/OperationDisplay.cs
new file mode 100644
index 0000000000000..37c6c6ec60d6b
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/OperationDisplay.cs
@@ -0,0 +1,62 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The object that represents the operation.
+ ///
+ public partial class OperationDisplay
+ {
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ public OperationDisplay() { }
+
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ /// Service provider: Microsoft.Billing
+ /// Resource on which the operation is
+ /// performed: Invoice, etc.
+ /// Operation type: Read, write, delete,
+ /// etc.
+ public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string))
+ {
+ Provider = provider;
+ Resource = resource;
+ Operation = operation;
+ }
+
+ ///
+ /// Gets service provider: Microsoft.Billing
+ ///
+ [JsonProperty(PropertyName = "provider")]
+ public string Provider { get; protected set; }
+
+ ///
+ /// Gets resource on which the operation is performed: Invoice, etc.
+ ///
+ [JsonProperty(PropertyName = "resource")]
+ public string Resource { get; protected set; }
+
+ ///
+ /// Gets operation type: Read, write, delete, etc.
+ ///
+ [JsonProperty(PropertyName = "operation")]
+ public string Operation { get; protected set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Page.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Page.cs
new file mode 100644
index 0000000000000..b6b11b162e990
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Page.cs
@@ -0,0 +1,55 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Rest;
+ using Rest.Azure;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+
+ ///
+ /// Defines a page in Azure responses.
+ ///
+ /// Type of the page content items
+ [JsonObject]
+ public class Page : IPage
+ {
+ ///
+ /// Gets the link to the next page.
+ ///
+ [JsonProperty("nextLink")]
+ public string NextPageLink { get; private set; }
+
+ [JsonProperty("value")]
+ private IList Items{ get; set; }
+
+ ///
+ /// Returns an enumerator that iterates through the collection.
+ ///
+ /// A an enumerator that can be used to iterate through the collection.
+ public IEnumerator GetEnumerator()
+ {
+ return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator();
+ }
+
+ ///
+ /// Returns an enumerator that iterates through the collection.
+ ///
+ /// A an enumerator that can be used to iterate through the collection.
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Resource.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Resource.cs
new file mode 100644
index 0000000000000..0b969035f40fa
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Models/Resource.cs
@@ -0,0 +1,62 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing.Models
+{
+ using Azure;
+ using Management;
+ using Billing;
+ using Rest;
+ using Rest.Azure;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The Resource model definition.
+ ///
+ public partial class Resource : IResource
+ {
+ ///
+ /// Initializes a new instance of the Resource class.
+ ///
+ public Resource() { }
+
+ ///
+ /// Initializes a new instance of the Resource class.
+ ///
+ /// Resource Id
+ /// Resource name
+ /// Resource type
+ public Resource(string id = default(string), string name = default(string), string type = default(string))
+ {
+ Id = id;
+ Name = name;
+ Type = type;
+ }
+
+ ///
+ /// Gets resource Id
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; protected set; }
+
+ ///
+ /// Gets resource name
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; protected set; }
+
+ ///
+ /// Gets resource type
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; protected set; }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Operations.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Operations.cs
new file mode 100644
index 0000000000000..73e8bd4355b7a
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/Operations.cs
@@ -0,0 +1,391 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using 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;
+
+ ///
+ /// Operations operations.
+ ///
+ internal partial class Operations : IServiceOperations, IOperations
+ {
+ ///
+ /// Initializes a new instance of the Operations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal Operations(BillingClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the BillingClient
+ ///
+ public BillingClient Client { get; private set; }
+
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// 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>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/operations").ToString();
+ 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 System.Net.Http.HttpRequestMessage();
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new System.Net.Http.HttpMethod("GET");
+ _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;
+ // 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;
+ }
+
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ 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("GET");
+ _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;
+ // 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/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/OperationsExtensions.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/OperationsExtensions.cs
new file mode 100644
index 0000000000000..da2c4e33312b1
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Generated/OperationsExtensions.cs
@@ -0,0 +1,88 @@
+// 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 1.0.0.0
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+
+namespace Microsoft.Azure.Management.Billing
+{
+ using Azure;
+ using Management;
+ using Rest;
+ using Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for Operations.
+ ///
+ public static partial class OperationsExtensions
+ {
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ public static IPage List(this IOperations operations)
+ {
+ return operations.ListAsync().GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListNext(this IOperations operations, string nextPageLink)
+ {
+ return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all of the available billing REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
+
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Microsoft.Azure.Management.Billing.xproj b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Microsoft.Azure.Management.Billing.xproj
new file mode 100644
index 0000000000000..b22f43eab37fb
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Microsoft.Azure.Management.Billing.xproj
@@ -0,0 +1,19 @@
+
+
+
+ 14.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+ 1370136c-378a-46ed-9d4e-db5a925709d4
+ Microsoft.Azure.Management.Billing
+ .\obj
+ .\bin\
+ v4.5.2
+
+
+ 2.0
+
+
+
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Properties/AssemblyInfo.cs b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000000..4ddab9d8681fa
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/Properties/AssemblyInfo.cs
@@ -0,0 +1,19 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System.Reflection;
+using System.Resources;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Microsoft Azure Billing Management Library")]
+[assembly: AssemblyDescription("Provides management functionality for Microsoft Azure Billing.")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Azure .NET SDK")]
+[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
\ No newline at end of file
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/generate.cmd b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/generate.cmd
new file mode 100644
index 0000000000000..8c5b2e6e662dd
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/generate.cmd
@@ -0,0 +1,17 @@
+::
+:: Microsoft Azure SDK for Net - Generate library code
+:: Copyright (C) Microsoft Corporation. All Rights Reserved.
+::
+
+@echo off
+set autoRestVersion=1.0.0-Nightly20170209
+if "%1" == "" (
+ set specFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-billing/2017-02-27-preview/swagger/billing.json"
+) else (
+ set specFile="%1"
+)
+set repoRoot=%~dp0..\..\..\..
+set generateFolder=%~dp0Generated
+
+if exist %generateFolder% rd /S /Q %generateFolder%
+call "%repoRoot%\tools\autorest.gen.cmd" %specFile% Microsoft.Azure.Management.Billing %autoRestVersion% %generateFolder% "MICROSOFT_MIT" "-FT 2"
diff --git a/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/project.json b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/project.json
new file mode 100644
index 0000000000000..4ccba3ff47ab0
--- /dev/null
+++ b/src/ResourceManagement/Billing/Microsoft.Azure.Management.Billing/project.json
@@ -0,0 +1,54 @@
+{
+ "version": "1.0.0-preview",
+ "description": "Microsoft Azure Billing Management Library",
+ "authors": [ "Microsoft" ],
+
+ "packOptions": {
+ "summary": "Microsoft Azure Billing Management Library",
+ "iconUrl": "http://go.microsoft.com/fwlink/?LinkID=288890",
+ "projectUrl": "https://github.com/Azure/azure-sdk-for-net",
+ "licenseUrl": "https://raw.githubusercontent.com/Microsoft/dotnet/master/LICENSE",
+ "tags": [ "Microsoft Azure Billing management", "Billing", "Billing management", "REST HTTP client", "windowsazureofficial" ],
+ "requireLicenseAcceptance": true
+ },
+
+ "buildOptions": {
+ "delaySign": true,
+ "publicSign": false,
+ "keyFile": "../../../../tools/MSSharedLibKey.snk"
+ },
+
+ "dependencies": {
+ },
+
+ "frameworks": {
+ "net45": {
+ "dependencies": {
+ "Microsoft.Rest.ClientRuntime.Azure": "[3.1.0,4.0.0)",
+ "Microsoft.Rest.ClientRuntime": "[2.1.0,3.0.0)"
+ }
+ },
+ "netstandard1.5": {
+ "imports": ["dnxcore50"],
+ "buildOptions": { "define": [ "PORTABLE" ] },
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1",
+ "System.Diagnostics.Tools": "4.0.1",
+ "System.Net.Http": "4.1.0",
+ "System.Runtime.Serialization.Primitives": "4.1.1",
+ "System.Threading.Tasks": "4.0.11",
+ "Microsoft.Rest.ClientRuntime.Azure": "[3.3.1,4.0.0)",
+ "Microsoft.Rest.ClientRuntime": "[2.3.1,3.0)"
+ }
+ },
+ "netstandard1.1": {
+ "imports": ["dnxcore50"],
+ "buildOptions": { "define": [ "PORTABLE" ] },
+ "dependencies": {
+ "System.Runtime.Serialization.Primitives": "4.1.1",
+ "Microsoft.Rest.ClientRuntime.Azure": "[3.3.1,4.0.0)",
+ "Microsoft.Rest.ClientRuntime": "[2.3.1,3.0)"
+ }
+ }
+ }
+}
diff --git a/src/ResourceManagement/Billing/global.json b/src/ResourceManagement/Billing/global.json
new file mode 100644
index 0000000000000..e87a9d0a6a343
--- /dev/null
+++ b/src/ResourceManagement/Billing/global.json
@@ -0,0 +1,3 @@
+{
+ "projects": [ "Microsoft.Azure.Management.Billing", "Billing.Tests" ]
+}