From c7ecbb39d990b588b438b2ad923aab4c395dbef9 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Thu, 23 Apr 2020 00:27:51 +0000 Subject: [PATCH] Generated from f8b941ddb4f72ae7514c222cf7efb1eabd0c09a1 Update readme.md --- .../src/Generated/ISubscriptionClient.cs | 25 +- .../ISubscriptionFactoryOperations.cs | 139 -- .../src/Generated/ISubscriptionOperations.cs | 233 ++- .../src/Generated/ISubscriptionsOperations.cs | 186 --- .../src/Generated/ITenantsOperations.cs | 68 - .../src/Generated/Models/Location.cs | 94 -- ...ModernCspSubscriptionCreationParameters.cs | 94 ++ .../ModernSubscriptionCreationParameters.cs | 16 +- .../src/Generated/Models/Page.cs | 53 - .../src/Generated/Models/Page1.cs | 53 - .../src/Generated/Models/SpendingLimit.cs | 66 - ...ubscriptionCreateCspSubscriptionHeaders.cs | 66 + ... SubscriptionCreateSubscriptionHeaders.cs} | 10 +- ...SubscriptionInEnrollmentAccountHeaders.cs} | 12 +- .../Models/SubscriptionCreationParameters.cs | 10 +- .../src/Generated/Models/SubscriptionModel.cs | 105 -- .../Generated/Models/SubscriptionOperation.cs | 68 - .../Models/SubscriptionOperationListResult.cs | 56 - .../Generated/Models/SubscriptionPolicies.cs | 75 - .../src/Generated/Models/SubscriptionState.cs | 78 - .../Generated/Models/TenantIdDescription.cs | 63 - .../src/Generated/Operations.cs | 16 +- .../Generated/SdkInfo_SubscriptionClient.cs | 23 +- .../src/Generated/SubscriptionClient.cs | 31 +- .../SubscriptionFactoryOperations.cs | 524 ------- ...SubscriptionFactoryOperationsExtensions.cs | 209 --- .../SubscriptionOperationOperations.cs | 10 +- .../src/Generated/SubscriptionOperations.cs | 1139 ++++++++++++++- .../SubscriptionOperationsExtensions.cs | 388 ++++- .../src/Generated/SubscriptionsOperations.cs | 1296 ----------------- .../SubscriptionsOperationsExtensions.cs | 275 ---- .../src/Generated/TenantsOperations.cs | 392 ----- .../Generated/TenantsOperationsExtensions.cs | 87 -- 33 files changed, 1960 insertions(+), 4000 deletions(-) delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionFactoryOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs create mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernCspSubscriptionCreationParameters.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs create mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateCspSubscriptionHeaders.cs rename sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/{SubscriptionFactoryCreateSubscriptionHeaders.cs => SubscriptionCreateSubscriptionHeaders.cs} (83%) rename sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/{SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders.cs => SubscriptionCreateSubscriptionInEnrollmentAccountHeaders.cs} (79%) delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperation.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperationListResult.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperationsExtensions.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs delete mode 100644 sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs index 97083c5959453..2d2b8dc07fb0a 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionClient.cs @@ -40,6 +40,12 @@ public partial interface ISubscriptionClient : System.IDisposable /// ServiceClientCredentials Credentials { get; } + /// + /// Version of the API to be used with the client request. Current + /// version is 2019-10-01-preview + /// + string ApiVersion { get; } + /// /// The preferred language for the response. /// @@ -60,34 +66,19 @@ public partial interface ISubscriptionClient : System.IDisposable /// - /// Gets the ISubscriptionsOperations. + /// Gets the ISubscriptionOperations. /// - ISubscriptionsOperations Subscriptions { get; } + ISubscriptionOperations Subscription { get; } /// /// Gets the ISubscriptionOperationOperations. /// ISubscriptionOperationOperations SubscriptionOperation { get; } - /// - /// Gets the ISubscriptionFactoryOperations. - /// - ISubscriptionFactoryOperations SubscriptionFactory { get; } - - /// - /// Gets the ISubscriptionOperations. - /// - ISubscriptionOperations SubscriptionOperations { get; } - /// /// Gets the IOperations. /// IOperations Operations { get; } - /// - /// Gets the ITenantsOperations. - /// - ITenantsOperations Tenants { get; } - } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionFactoryOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionFactoryOperations.cs deleted file mode 100644 index a4b1ac267d9a8..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionFactoryOperations.cs +++ /dev/null @@ -1,139 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubscriptionFactoryOperations operations. - /// - public partial interface ISubscriptionFactoryOperations - { - /// - /// The operation to create a new Azure subscription - /// - /// - /// The name of the Microsoft Customer Agreement billing account for - /// which you want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which - /// you want to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> CreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates an Azure subscription - /// - /// - /// The name of the enrollment account to which the subscription will - /// be billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The operation to create a new Azure subscription - /// - /// - /// The name of the Microsoft Customer Agreement billing account for - /// which you want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which - /// you want to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> BeginCreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Creates an Azure subscription - /// - /// - /// The name of the enrollment account to which the subscription will - /// be billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs index c1650a27a93ef..6262a787e85bd 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionOperations.cs @@ -24,9 +24,236 @@ namespace Microsoft.Azure.Management.Subscription public partial interface ISubscriptionOperations { /// - /// Lists all of the available pending Microsoft.Subscription API - /// operations. + /// Creates an Azure subscription /// + /// + /// The name of the enrollment account to which the subscription will + /// be billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to cancel a subscription + /// + /// + /// Subscription Id. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CancelWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to rename a subscription + /// + /// + /// Subscription Id. + /// + /// + /// Subscription Name + /// + /// + /// 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> RenameWithHttpMessagesAsync(string subscriptionId, SubscriptionName body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to enable a subscription + /// + /// + /// Subscription Id. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> EnableWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for + /// which you want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which + /// you want to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which + /// you want to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> CreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for + /// which you want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> CreateCspSubscriptionWithHttpMessagesAsync(string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates an Azure subscription + /// + /// + /// The name of the enrollment account to which the subscription will + /// be billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for + /// which you want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which + /// you want to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which + /// you want to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> BeginCreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for + /// which you want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// /// /// The headers that will be added to request. /// @@ -42,6 +269,6 @@ public partial interface ISubscriptionOperations /// /// Thrown when a required parameter is null /// - Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task> BeginCreateCspSubscriptionWithHttpMessagesAsync(string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs deleted file mode 100644 index ef734314a95c8..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ISubscriptionsOperations.cs +++ /dev/null @@ -1,186 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubscriptionsOperations operations. - /// - public partial interface ISubscriptionsOperations - { - /// - /// The operation to cancel a subscription - /// - /// - /// Subscription Id. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> CancelWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The operation to rename a subscription - /// - /// - /// Subscription Id. - /// - /// - /// Subscription Name - /// - /// - /// 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> RenameWithHttpMessagesAsync(string subscriptionId, SubscriptionName body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// The operation to enable a subscription - /// - /// - /// Subscription Id. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> EnableWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for - /// resource providers; however, each resource provider may support a - /// subset of this list. - /// - /// - /// The ID of the target subscription. - /// - /// - /// 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>> ListLocationsWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets details about a specified subscription. - /// - /// - /// The ID of the target subscription. - /// - /// - /// 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 subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// 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)); - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs deleted file mode 100644 index c644814aa1560..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/ITenantsOperations.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// TenantsOperations operations. - /// - public partial interface ITenantsOperations - { - /// - /// Gets the tenants for your account. - /// - /// - /// 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)); - /// - /// Gets the tenants for your account. - /// - /// - /// 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs deleted file mode 100644 index da2f8289c695e..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Location.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Location information. - /// - public partial class Location - { - /// - /// Initializes a new instance of the Location class. - /// - public Location() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the Location class. - /// - /// The fully qualified ID of the location. For - /// example, - /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. - /// The subscription ID. - /// The location name. - /// The display name of the location. - /// The latitude of the location. - /// The longitude of the location. - public Location(string id = default(string), string subscriptionId = default(string), string name = default(string), string displayName = default(string), string latitude = default(string), string longitude = default(string)) - { - Id = id; - SubscriptionId = subscriptionId; - Name = name; - DisplayName = displayName; - Latitude = latitude; - Longitude = longitude; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the fully qualified ID of the location. For example, - /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the subscription ID. - /// - [JsonProperty(PropertyName = "subscriptionId")] - public string SubscriptionId { get; private set; } - - /// - /// Gets the location name. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } - - /// - /// Gets the display name of the location. - /// - [JsonProperty(PropertyName = "displayName")] - public string DisplayName { get; private set; } - - /// - /// Gets the latitude of the location. - /// - [JsonProperty(PropertyName = "latitude")] - public string Latitude { get; private set; } - - /// - /// Gets the longitude of the location. - /// - [JsonProperty(PropertyName = "longitude")] - public string Longitude { get; private set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernCspSubscriptionCreationParameters.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernCspSubscriptionCreationParameters.cs new file mode 100644 index 0000000000000..18cc8a881237c --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernCspSubscriptionCreationParameters.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The parameters required to create a new CSP subscription. + /// + public partial class ModernCspSubscriptionCreationParameters + { + /// + /// Initializes a new instance of the + /// ModernCspSubscriptionCreationParameters class. + /// + public ModernCspSubscriptionCreationParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ModernCspSubscriptionCreationParameters class. + /// + /// The friendly name of the + /// subscription. + /// The SKU ID of the Azure plan. Azure plan + /// determines the pricing and service-level agreement of the + /// subscription. Use 001 for Microsoft Azure Plan and 002 for + /// Microsoft Azure Plan for DevTest. + /// Reseller ID, basically MPN Id. + public ModernCspSubscriptionCreationParameters(string displayName, string skuId, string resellerId = default(string)) + { + DisplayName = displayName; + SkuId = skuId; + ResellerId = resellerId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the friendly name of the subscription. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the SKU ID of the Azure plan. Azure plan determines + /// the pricing and service-level agreement of the subscription. Use + /// 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for + /// DevTest. + /// + [JsonProperty(PropertyName = "skuId")] + public string SkuId { get; set; } + + /// + /// Gets or sets reseller ID, basically MPN Id. + /// + [JsonProperty(PropertyName = "resellerId")] + public string ResellerId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DisplayName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); + } + if (SkuId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SkuId"); + } + } + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernSubscriptionCreationParameters.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernSubscriptionCreationParameters.cs index 19ae62c3a0b9d..01edbf8c386c9 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernSubscriptionCreationParameters.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/ModernSubscriptionCreationParameters.cs @@ -36,8 +36,6 @@ public ModernSubscriptionCreationParameters() /// /// The friendly name of the /// subscription. - /// The ARM ID of the billing profile - /// for which you want to create the subscription. /// The SKU ID of the Azure plan. Azure plan /// determines the pricing and service-level agreement of the /// subscription. Use 001 for Microsoft Azure Plan and 002 for @@ -51,10 +49,9 @@ public ModernSubscriptionCreationParameters() /// group to which this subscription will be associated. /// Additional, untyped parameters /// to support custom subscription creation scenarios. - public ModernSubscriptionCreationParameters(string displayName, string billingProfileId, string skuId, string costCenter = default(string), AdPrincipal owner = default(AdPrincipal), string managementGroupId = default(string), IDictionary additionalParameters = default(IDictionary)) + public ModernSubscriptionCreationParameters(string displayName, string skuId, string costCenter = default(string), AdPrincipal owner = default(AdPrincipal), string managementGroupId = default(string), IDictionary additionalParameters = default(IDictionary)) { DisplayName = displayName; - BillingProfileId = billingProfileId; SkuId = skuId; CostCenter = costCenter; Owner = owner; @@ -74,13 +71,6 @@ public ModernSubscriptionCreationParameters() [JsonProperty(PropertyName = "displayName")] public string DisplayName { get; set; } - /// - /// Gets or sets the ARM ID of the billing profile for which you want - /// to create the subscription. - /// - [JsonProperty(PropertyName = "billingProfileId")] - public string BillingProfileId { get; set; } - /// /// Gets or sets the SKU ID of the Azure plan. Azure plan determines /// the pricing and service-level agreement of the subscription. Use @@ -131,10 +121,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); } - if (BillingProfileId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "BillingProfileId"); - } if (SkuId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "SkuId"); diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs deleted file mode 100644 index b7b259149ab93..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Microsoft.Rest; - using Microsoft.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("")] - 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs deleted file mode 100644 index 9d88e45ba6834..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/Page1.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Microsoft.Rest; - using Microsoft.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 Page1 : 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs deleted file mode 100644 index b99c7dd697bbf..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SpendingLimit.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for SpendingLimit. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum SpendingLimit - { - [EnumMember(Value = "On")] - On, - [EnumMember(Value = "Off")] - Off, - [EnumMember(Value = "CurrentPeriodOff")] - CurrentPeriodOff - } - internal static class SpendingLimitEnumExtension - { - internal static string ToSerializedValue(this SpendingLimit? value) - { - return value == null ? null : ((SpendingLimit)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this SpendingLimit value) - { - switch( value ) - { - case SpendingLimit.On: - return "On"; - case SpendingLimit.Off: - return "Off"; - case SpendingLimit.CurrentPeriodOff: - return "CurrentPeriodOff"; - } - return null; - } - - internal static SpendingLimit? ParseSpendingLimit(this string value) - { - switch( value ) - { - case "On": - return SpendingLimit.On; - case "Off": - return SpendingLimit.Off; - case "CurrentPeriodOff": - return SpendingLimit.CurrentPeriodOff; - } - return null; - } - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateCspSubscriptionHeaders.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateCspSubscriptionHeaders.cs new file mode 100644 index 0000000000000..0270e18a4e5bd --- /dev/null +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateCspSubscriptionHeaders.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Subscription.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateCspSubscription operation. + /// + public partial class SubscriptionCreateCspSubscriptionHeaders + { + /// + /// Initializes a new instance of the + /// SubscriptionCreateCspSubscriptionHeaders class. + /// + public SubscriptionCreateCspSubscriptionHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SubscriptionCreateCspSubscriptionHeaders class. + /// + /// GET this URL to retrieve the status of the + /// asynchronous operation. + /// The amount of delay to use while the + /// status of the operation is checked. The value is expressed in + /// seconds. + public SubscriptionCreateCspSubscriptionHeaders(string location = default(string), int? retryAfter = default(int?)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets GET this URL to retrieve the status of the + /// asynchronous operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets the amount of delay to use while the status of the + /// operation is checked. The value is expressed in seconds. + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionHeaders.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionHeaders.cs similarity index 83% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionHeaders.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionHeaders.cs index fa602c14e1f75..a8230f26ada1e 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionHeaders.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionHeaders.cs @@ -16,27 +16,27 @@ namespace Microsoft.Azure.Management.Subscription.Models /// /// Defines headers for CreateSubscription operation. /// - public partial class SubscriptionFactoryCreateSubscriptionHeaders + public partial class SubscriptionCreateSubscriptionHeaders { /// /// Initializes a new instance of the - /// SubscriptionFactoryCreateSubscriptionHeaders class. + /// SubscriptionCreateSubscriptionHeaders class. /// - public SubscriptionFactoryCreateSubscriptionHeaders() + public SubscriptionCreateSubscriptionHeaders() { CustomInit(); } /// /// Initializes a new instance of the - /// SubscriptionFactoryCreateSubscriptionHeaders class. + /// SubscriptionCreateSubscriptionHeaders class. /// /// GET this URL to retrieve the status of the /// asynchronous operation. /// The amount of delay to use while the /// status of the operation is checked. The value is expressed in /// seconds. - public SubscriptionFactoryCreateSubscriptionHeaders(string location = default(string), int? retryAfter = default(int?)) + public SubscriptionCreateSubscriptionHeaders(string location = default(string), int? retryAfter = default(int?)) { Location = location; RetryAfter = retryAfter; diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionInEnrollmentAccountHeaders.cs similarity index 79% rename from sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders.cs rename to sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionInEnrollmentAccountHeaders.cs index 759ff1d79a48f..98a127191fdd1 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreateSubscriptionInEnrollmentAccountHeaders.cs @@ -16,29 +16,27 @@ namespace Microsoft.Azure.Management.Subscription.Models /// /// Defines headers for CreateSubscriptionInEnrollmentAccount operation. /// - public partial class SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders + public partial class SubscriptionCreateSubscriptionInEnrollmentAccountHeaders { /// /// Initializes a new instance of the - /// SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders - /// class. + /// SubscriptionCreateSubscriptionInEnrollmentAccountHeaders class. /// - public SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders() + public SubscriptionCreateSubscriptionInEnrollmentAccountHeaders() { CustomInit(); } /// /// Initializes a new instance of the - /// SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders - /// class. + /// SubscriptionCreateSubscriptionInEnrollmentAccountHeaders class. /// /// GET this URL to retrieve the status of the /// asynchronous operation. /// The amount of delay to use while the /// status of the operation is checked. The value is expressed in /// seconds. - public SubscriptionFactoryCreateSubscriptionInEnrollmentAccountHeaders(string location = default(string), string retryAfter = default(string)) + public SubscriptionCreateSubscriptionInEnrollmentAccountHeaders(string location = default(string), string retryAfter = default(string)) { Location = location; RetryAfter = retryAfter; diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreationParameters.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreationParameters.cs index fc5033f6b3648..77e251905e919 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreationParameters.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionCreationParameters.cs @@ -36,6 +36,7 @@ public SubscriptionCreationParameters() /// /// The display name of the /// subscription. + /// The Management Group Id. /// The list of principals that should be granted /// Owner access on the subscription. Principals should be of type /// User, Service Principal or Security Group. @@ -46,9 +47,10 @@ public SubscriptionCreationParameters() /// values include: 'MS-AZR-0017P', 'MS-AZR-0148P' /// Additional, untyped parameters /// to support custom subscription creation scenarios. - public SubscriptionCreationParameters(string displayName = default(string), IList owners = default(IList), string offerType = default(string), IDictionary additionalParameters = default(IDictionary)) + public SubscriptionCreationParameters(string displayName = default(string), string managementGroupId = default(string), IList owners = default(IList), string offerType = default(string), IDictionary additionalParameters = default(IDictionary)) { DisplayName = displayName; + ManagementGroupId = managementGroupId; Owners = owners; OfferType = offerType; AdditionalParameters = additionalParameters; @@ -66,6 +68,12 @@ public SubscriptionCreationParameters() [JsonProperty(PropertyName = "displayName")] public string DisplayName { get; set; } + /// + /// Gets or sets the Management Group Id. + /// + [JsonProperty(PropertyName = "managementGroupId")] + public string ManagementGroupId { get; set; } + /// /// Gets or sets the list of principals that should be granted Owner /// access on the subscription. Principals should be of type User, diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs deleted file mode 100644 index 58b6ccf61b5ba..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionModel.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Subscription information. - /// - public partial class SubscriptionModel - { - /// - /// Initializes a new instance of the SubscriptionModel class. - /// - public SubscriptionModel() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionModel class. - /// - /// The fully qualified ID for the subscription. For - /// example, - /// /subscriptions/00000000-0000-0000-0000-000000000000. - /// The subscription ID. - /// The subscription display name. - /// The subscription state. Possible values are - /// Enabled, Warned, PastDue, Disabled, and Deleted. Possible values - /// include: 'Enabled', 'Warned', 'PastDue', 'Disabled', - /// 'Deleted' - /// The subscription - /// policies. - /// The authorization source of the - /// request. Valid values are one or more combinations of Legacy, - /// RoleBased, Bypassed, Direct and Management. For example, 'Legacy, - /// RoleBased'. - public SubscriptionModel(string id = default(string), string subscriptionId = default(string), string displayName = default(string), SubscriptionState? state = default(SubscriptionState?), SubscriptionPolicies subscriptionPolicies = default(SubscriptionPolicies), string authorizationSource = default(string)) - { - Id = id; - SubscriptionId = subscriptionId; - DisplayName = displayName; - State = state; - SubscriptionPolicies = subscriptionPolicies; - AuthorizationSource = authorizationSource; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the fully qualified ID for the subscription. For example, - /// /subscriptions/00000000-0000-0000-0000-000000000000. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the subscription ID. - /// - [JsonProperty(PropertyName = "subscriptionId")] - public string SubscriptionId { get; private set; } - - /// - /// Gets the subscription display name. - /// - [JsonProperty(PropertyName = "displayName")] - public string DisplayName { get; private set; } - - /// - /// Gets the subscription state. Possible values are Enabled, Warned, - /// PastDue, Disabled, and Deleted. Possible values include: 'Enabled', - /// 'Warned', 'PastDue', 'Disabled', 'Deleted' - /// - [JsonProperty(PropertyName = "state")] - public SubscriptionState? State { get; private set; } - - /// - /// Gets or sets the subscription policies. - /// - [JsonProperty(PropertyName = "subscriptionPolicies")] - public SubscriptionPolicies SubscriptionPolicies { get; set; } - - /// - /// Gets or sets the authorization source of the request. Valid values - /// are one or more combinations of Legacy, RoleBased, Bypassed, Direct - /// and Management. For example, 'Legacy, RoleBased'. - /// - [JsonProperty(PropertyName = "authorizationSource")] - public string AuthorizationSource { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperation.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperation.cs deleted file mode 100644 index 89b66c82fd259..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperation.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// status of the subscription POST operation. - /// - public partial class SubscriptionOperation - { - /// - /// Initializes a new instance of the SubscriptionOperation class. - /// - public SubscriptionOperation() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionOperation class. - /// - /// The operation Id. - /// Status of the pending subscription - /// Status Detail of the pending - /// subscription - public SubscriptionOperation(string id = default(string), string status = default(string), string statusDetail = default(string)) - { - Id = id; - Status = status; - StatusDetail = statusDetail; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the operation Id. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets or sets status of the pending subscription - /// - [JsonProperty(PropertyName = "status")] - public string Status { get; set; } - - /// - /// Gets or sets status Detail of the pending subscription - /// - [JsonProperty(PropertyName = "statusDetail")] - public string StatusDetail { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperationListResult.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperationListResult.cs deleted file mode 100644 index 4dc7600ed0ac0..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionOperationListResult.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// A list of pending subscription operations. - /// - public partial class SubscriptionOperationListResult - { - /// - /// Initializes a new instance of the SubscriptionOperationListResult - /// class. - /// - public SubscriptionOperationListResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionOperationListResult - /// class. - /// - /// A list of pending - /// SubscriptionOperations - public SubscriptionOperationListResult(IList value = default(IList)) - { - Value = value; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets a list of pending SubscriptionOperations - /// - [JsonProperty(PropertyName = "value")] - public IList Value { get; set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs deleted file mode 100644 index 78258171c6302..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionPolicies.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Subscription policies. - /// - public partial class SubscriptionPolicies - { - /// - /// Initializes a new instance of the SubscriptionPolicies class. - /// - public SubscriptionPolicies() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the SubscriptionPolicies class. - /// - /// The subscription location - /// placement ID. The ID indicates which regions are visible for a - /// subscription. For example, a subscription with a location placement - /// Id of Public_2014-09-01 has access to Azure public regions. - /// The subscription quota ID. - /// The subscription spending limit. - /// Possible values include: 'On', 'Off', 'CurrentPeriodOff' - public SubscriptionPolicies(string locationPlacementId = default(string), string quotaId = default(string), SpendingLimit? spendingLimit = default(SpendingLimit?)) - { - LocationPlacementId = locationPlacementId; - QuotaId = quotaId; - SpendingLimit = spendingLimit; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the subscription location placement ID. The ID indicates which - /// regions are visible for a subscription. For example, a subscription - /// with a location placement Id of Public_2014-09-01 has access to - /// Azure public regions. - /// - [JsonProperty(PropertyName = "locationPlacementId")] - public string LocationPlacementId { get; private set; } - - /// - /// Gets the subscription quota ID. - /// - [JsonProperty(PropertyName = "quotaId")] - public string QuotaId { get; private set; } - - /// - /// Gets the subscription spending limit. Possible values include: - /// 'On', 'Off', 'CurrentPeriodOff' - /// - [JsonProperty(PropertyName = "spendingLimit")] - public SpendingLimit? SpendingLimit { get; private set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs deleted file mode 100644 index 155901fb698f5..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/SubscriptionState.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; - using System.Runtime; - using System.Runtime.Serialization; - - /// - /// Defines values for SubscriptionState. - /// - [JsonConverter(typeof(StringEnumConverter))] - public enum SubscriptionState - { - [EnumMember(Value = "Enabled")] - Enabled, - [EnumMember(Value = "Warned")] - Warned, - [EnumMember(Value = "PastDue")] - PastDue, - [EnumMember(Value = "Disabled")] - Disabled, - [EnumMember(Value = "Deleted")] - Deleted - } - internal static class SubscriptionStateEnumExtension - { - internal static string ToSerializedValue(this SubscriptionState? value) - { - return value == null ? null : ((SubscriptionState)value).ToSerializedValue(); - } - - internal static string ToSerializedValue(this SubscriptionState value) - { - switch( value ) - { - case SubscriptionState.Enabled: - return "Enabled"; - case SubscriptionState.Warned: - return "Warned"; - case SubscriptionState.PastDue: - return "PastDue"; - case SubscriptionState.Disabled: - return "Disabled"; - case SubscriptionState.Deleted: - return "Deleted"; - } - return null; - } - - internal static SubscriptionState? ParseSubscriptionState(this string value) - { - switch( value ) - { - case "Enabled": - return SubscriptionState.Enabled; - case "Warned": - return SubscriptionState.Warned; - case "PastDue": - return SubscriptionState.PastDue; - case "Disabled": - return SubscriptionState.Disabled; - case "Deleted": - return SubscriptionState.Deleted; - } - return null; - } - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs deleted file mode 100644 index ad20b421ddf62..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Models/TenantIdDescription.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription.Models -{ - using Newtonsoft.Json; - using System.Linq; - - /// - /// Tenant Id information. - /// - public partial class TenantIdDescription - { - /// - /// Initializes a new instance of the TenantIdDescription class. - /// - public TenantIdDescription() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the TenantIdDescription class. - /// - /// The fully qualified ID of the tenant. For example, - /// /tenants/00000000-0000-0000-0000-000000000000. - /// The tenant ID. For example, - /// 00000000-0000-0000-0000-000000000000. - public TenantIdDescription(string id = default(string), string tenantId = default(string)) - { - Id = id; - TenantId = tenantId; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets the fully qualified ID of the tenant. For example, - /// /tenants/00000000-0000-0000-0000-000000000000. - /// - [JsonProperty(PropertyName = "id")] - public string Id { get; private set; } - - /// - /// Gets the tenant ID. For example, - /// 00000000-0000-0000-0000-000000000000. - /// - [JsonProperty(PropertyName = "tenantId")] - public string TenantId { get; private set; } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs index 439f6ee6119b5..c27dad7b322f0 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/Operations.cs @@ -65,12 +65,21 @@ internal Operations(SubscriptionClient client) /// /// 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)) { - string apiVersion = "2018-03-01-preview"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -78,7 +87,6 @@ internal Operations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } @@ -86,9 +94,9 @@ internal Operations(SubscriptionClient client) var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/operations").ToString(); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs index d9fde8d12ae08..6a2a1668e396f 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SdkInfo_SubscriptionClient.cs @@ -19,27 +19,12 @@ public static IEnumerable> ApiInfo_SubscriptionCli { return new Tuple[] { - new Tuple("Billing", "SubscriptionFactory", "2018-03-01-preview"), - new Tuple("Billing", "SubscriptionFactory", "2018-11-01-preview"), - new Tuple("Subscription", "Operations", "2018-03-01-preview"), - new Tuple("Subscription", "SubscriptionOperation", "2018-11-01-preview"), - new Tuple("Subscription", "SubscriptionOperations", "2018-03-01-preview"), - new Tuple("Subscription", "Subscriptions", "2019-03-01-preview"), - new Tuple("SubscriptionClient", "Subscriptions", "2016-06-01"), - new Tuple("SubscriptionClient", "Tenants", "2016-06-01"), + new Tuple("Billing", "Subscription", "2019-10-01-preview"), + new Tuple("Subscription", "Operations", "2019-10-01-preview"), + new Tuple("Subscription", "Subscription", "2019-10-01-preview"), + new Tuple("Subscription", "SubscriptionOperation", "2019-10-01-preview"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "latest"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/subscription/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\github2\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "ae48ce6edc05501e9b78d93d6e36862599cdedb5"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs index 5f732c5369b0b..50c4a98509aed 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionClient.cs @@ -46,6 +46,12 @@ public partial class SubscriptionClient : ServiceClient, ISu /// public ServiceClientCredentials Credentials { get; private set; } + /// + /// Version of the API to be used with the client request. Current version is + /// 2019-10-01-preview + /// + public string ApiVersion { get; private set; } + /// /// The preferred language for the response. /// @@ -65,35 +71,20 @@ public partial class SubscriptionClient : ServiceClient, ISu public bool? GenerateClientRequestId { get; set; } /// - /// Gets the ISubscriptionsOperations. + /// Gets the ISubscriptionOperations. /// - public virtual ISubscriptionsOperations Subscriptions { get; private set; } + public virtual ISubscriptionOperations Subscription { get; private set; } /// /// Gets the ISubscriptionOperationOperations. /// public virtual ISubscriptionOperationOperations SubscriptionOperation { get; private set; } - /// - /// Gets the ISubscriptionFactoryOperations. - /// - public virtual ISubscriptionFactoryOperations SubscriptionFactory { get; private set; } - - /// - /// Gets the ISubscriptionOperations. - /// - public virtual ISubscriptionOperations SubscriptionOperations { get; private set; } - /// /// Gets the IOperations. /// public virtual IOperations Operations { get; private set; } - /// - /// Gets the ITenantsOperations. - /// - public virtual ITenantsOperations Tenants { get; private set; } - /// /// Initializes a new instance of the SubscriptionClient class. /// @@ -335,13 +326,11 @@ public SubscriptionClient(System.Uri baseUri, ServiceClientCredentials credentia /// private void Initialize() { - Subscriptions = new SubscriptionsOperations(this); + Subscription = new SubscriptionOperations(this); SubscriptionOperation = new SubscriptionOperationOperations(this); - SubscriptionFactory = new SubscriptionFactoryOperations(this); - SubscriptionOperations = new SubscriptionOperations(this); Operations = new Operations(this); - Tenants = new TenantsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2019-10-01-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperations.cs deleted file mode 100644 index 3f038282e47c5..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperations.cs +++ /dev/null @@ -1,524 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubscriptionFactoryOperations operations. - /// - internal partial class SubscriptionFactoryOperations : IServiceOperations, ISubscriptionFactoryOperations - { - /// - /// Initializes a new instance of the SubscriptionFactoryOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal SubscriptionFactoryOperations(SubscriptionClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SubscriptionClient - /// - public SubscriptionClient Client { get; private set; } - - /// - /// The operation to create a new Azure subscription - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginCreateSubscriptionWithHttpMessagesAsync(billingAccountName, invoiceSectionName, body, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// Creates an Azure subscription - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - public async Task> CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - // Send request - AzureOperationResponse _response = await BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, customHeaders, cancellationToken).ConfigureAwait(false); - return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); - } - - /// - /// The operation to create a new Azure subscription - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> BeginCreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (billingAccountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); - } - if (invoiceSectionName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionName"); - } - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - if (body != null) - { - body.Validate(); - } - string apiVersion = "2018-11-01-preview"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("billingAccountName", billingAccountName); - tracingParameters.Add("invoiceSectionName", invoiceSectionName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateSubscription", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription").ToString(); - _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); - _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - 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); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Creates an Azure subscription - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// 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> BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (enrollmentAccountName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "enrollmentAccountName"); - } - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - string apiVersion = "2018-03-01-preview"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("enrollmentAccountName", enrollmentAccountName); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("body", body); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateSubscriptionInEnrollmentAccount", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription").ToString(); - _url = _url.Replace("{enrollmentAccountName}", System.Uri.EscapeDataString(enrollmentAccountName)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 202) - { - 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); - } - } - try - { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperationsExtensions.cs deleted file mode 100644 index edd23ced2cf69..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionFactoryOperationsExtensions.cs +++ /dev/null @@ -1,209 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SubscriptionFactoryOperations. - /// - public static partial class SubscriptionFactoryOperationsExtensions - { - /// - /// The operation to create a new Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - public static SubscriptionCreationResult CreateSubscription(this ISubscriptionFactoryOperations operations, string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body) - { - return operations.CreateSubscriptionAsync(billingAccountName, invoiceSectionName, body).GetAwaiter().GetResult(); - } - - /// - /// The operation to create a new Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The cancellation token. - /// - public static async Task CreateSubscriptionAsync(this ISubscriptionFactoryOperations operations, string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateSubscriptionWithHttpMessagesAsync(billingAccountName, invoiceSectionName, body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates an Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - public static SubscriptionCreationResult CreateSubscriptionInEnrollmentAccount(this ISubscriptionFactoryOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body) - { - return operations.CreateSubscriptionInEnrollmentAccountAsync(enrollmentAccountName, body).GetAwaiter().GetResult(); - } - - /// - /// Creates an Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The cancellation token. - /// - public static async Task CreateSubscriptionInEnrollmentAccountAsync(this ISubscriptionFactoryOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The operation to create a new Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - public static SubscriptionCreationResult BeginCreateSubscription(this ISubscriptionFactoryOperations operations, string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body) - { - return operations.BeginCreateSubscriptionAsync(billingAccountName, invoiceSectionName, body).GetAwaiter().GetResult(); - } - - /// - /// The operation to create a new Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the Microsoft Customer Agreement billing account for which you - /// want to create the subscription. - /// - /// - /// The name of the invoice section in the billing account for which you want - /// to create the subscription. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateSubscriptionAsync(this ISubscriptionFactoryOperations operations, string billingAccountName, string invoiceSectionName, ModernSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateSubscriptionWithHttpMessagesAsync(billingAccountName, invoiceSectionName, body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Creates an Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - public static SubscriptionCreationResult BeginCreateSubscriptionInEnrollmentAccount(this ISubscriptionFactoryOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body) - { - return operations.BeginCreateSubscriptionInEnrollmentAccountAsync(enrollmentAccountName, body).GetAwaiter().GetResult(); - } - - /// - /// Creates an Azure subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// The name of the enrollment account to which the subscription will be - /// billed. - /// - /// - /// The subscription creation parameters. - /// - /// - /// The cancellation token. - /// - public static async Task BeginCreateSubscriptionInEnrollmentAccountAsync(this ISubscriptionFactoryOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationOperations.cs index 399db7ecfb0c4..198326f5a0e1f 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationOperations.cs @@ -84,7 +84,10 @@ internal SubscriptionOperationOperations(SubscriptionClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); } - string apiVersion = "2018-11-01-preview"; + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -93,7 +96,6 @@ internal SubscriptionOperationOperations(SubscriptionClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("operationId", operationId); - tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); } @@ -102,9 +104,9 @@ internal SubscriptionOperationOperations(SubscriptionClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/subscriptionOperations/{operationId}").ToString(); _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs index 2b1244325d903..1170e9d04398d 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperations.cs @@ -51,8 +51,214 @@ internal SubscriptionOperations(SubscriptionClient client) public SubscriptionClient Client { get; private set; } /// - /// Lists all of the available pending Microsoft.Subscription API operations. + /// Creates an Azure subscription /// + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to cancel a subscription + /// + /// + /// Subscription Id. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CancelWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "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("subscriptionId", subscriptionId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(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 HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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; + } + + /// + /// The operation to rename a subscription + /// + /// + /// Subscription Id. + /// + /// + /// Subscription Name + /// /// /// Headers that will be added to request. /// @@ -65,12 +271,29 @@ internal SubscriptionOperations(SubscriptionClient client) /// /// 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)) + public async Task> RenameWithHttpMessagesAsync(string subscriptionId, SubscriptionName body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - string apiVersion = "2018-03-01-preview"; + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -78,17 +301,19 @@ internal SubscriptionOperations(SubscriptionClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("body", body); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "Rename", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Subscription/subscriptionOperations").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); List _queryParameters = new List(); - if (apiVersion != null) + if (Client.ApiVersion != null) { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { @@ -97,7 +322,7 @@ internal SubscriptionOperations(SubscriptionClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -128,6 +353,12 @@ internal SubscriptionOperations(SubscriptionClient client) // Serialize Request string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } // Set Credentials if (Client.Credentials != null) { @@ -178,7 +409,7 @@ internal SubscriptionOperations(SubscriptionClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -191,7 +422,7 @@ internal SubscriptionOperations(SubscriptionClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -210,5 +441,891 @@ internal SubscriptionOperations(SubscriptionClient client) return _result; } + /// + /// The operation to enable a subscription + /// + /// + /// Subscription Id. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> EnableWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "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("subscriptionId", subscriptionId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(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 HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // 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; + } + + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateSubscriptionWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceSectionName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateCspSubscriptionWithHttpMessagesAsync(string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateCspSubscriptionWithHttpMessagesAsync(billingAccountName, customerName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates an Azure subscription + /// + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(string enrollmentAccountName, SubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (enrollmentAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "enrollmentAccountName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("enrollmentAccountName", enrollmentAccountName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateSubscriptionInEnrollmentAccount", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription").ToString(); + _url = _url.Replace("{enrollmentAccountName}", System.Uri.EscapeDataString(enrollmentAccountName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + 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); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> BeginCreateSubscriptionWithHttpMessagesAsync(string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (billingProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingProfileName"); + } + if (invoiceSectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "invoiceSectionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("billingProfileName", billingProfileName); + tracingParameters.Add("invoiceSectionName", invoiceSectionName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{billingProfileName}", System.Uri.EscapeDataString(billingProfileName)); + _url = _url.Replace("{invoiceSectionName}", System.Uri.EscapeDataString(invoiceSectionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + 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); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + /// + /// 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> BeginCreateCspSubscriptionWithHttpMessagesAsync(string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (billingAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "billingAccountName"); + } + if (customerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customerName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (body == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (body != null) + { + body.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("billingAccountName", billingAccountName); + tracingParameters.Add("customerName", customerName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateCspSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription").ToString(); + _url = _url.Replace("{billingAccountName}", System.Uri.EscapeDataString(billingAccountName)); + _url = _url.Replace("{customerName}", System.Uri.EscapeDataString(customerName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + 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); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + } } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs index b0704257cd4b2..1011107cc48fa 100644 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs +++ b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionOperationsExtensions.cs @@ -22,28 +22,404 @@ namespace Microsoft.Azure.Management.Subscription public static partial class SubscriptionOperationsExtensions { /// - /// Lists all of the available pending Microsoft.Subscription API operations. + /// Creates an Azure subscription /// /// /// The operations group for this extension method. /// - public static SubscriptionOperationListResult List(this ISubscriptionOperations operations) + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult CreateSubscriptionInEnrollmentAccount(this ISubscriptionOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body) + { + return operations.CreateSubscriptionInEnrollmentAccountAsync(enrollmentAccountName, body).GetAwaiter().GetResult(); + } + + /// + /// Creates an Azure subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateSubscriptionInEnrollmentAccountAsync(this ISubscriptionOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to cancel a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + public static CanceledSubscriptionId Cancel(this ISubscriptionOperations operations, string subscriptionId) + { + return operations.CancelAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// The operation to cancel a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAsync(this ISubscriptionOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CancelWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to rename a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// Subscription Name + /// + public static RenamedSubscriptionId Rename(this ISubscriptionOperations operations, string subscriptionId, SubscriptionName body) + { + return operations.RenameAsync(subscriptionId, body).GetAwaiter().GetResult(); + } + + /// + /// The operation to rename a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// Subscription Name + /// + /// + /// The cancellation token. + /// + public static async Task RenameAsync(this ISubscriptionOperations operations, string subscriptionId, SubscriptionName body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RenameWithHttpMessagesAsync(subscriptionId, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to enable a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + public static EnabledSubscriptionId Enable(this ISubscriptionOperations operations, string subscriptionId) + { + return operations.EnableAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// The operation to enable a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// Subscription Id. + /// + /// + /// The cancellation token. + /// + public static async Task EnableAsync(this ISubscriptionOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.EnableWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult CreateSubscription(this ISubscriptionOperations operations, string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body) + { + return operations.CreateSubscriptionAsync(billingAccountName, billingProfileName, invoiceSectionName, body).GetAwaiter().GetResult(); + } + + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateSubscriptionAsync(this ISubscriptionOperations operations, string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateSubscriptionWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceSectionName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult CreateCspSubscription(this ISubscriptionOperations operations, string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body) + { + return operations.CreateCspSubscriptionAsync(billingAccountName, customerName, body).GetAwaiter().GetResult(); + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateCspSubscriptionAsync(this ISubscriptionOperations operations, string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateCspSubscriptionWithHttpMessagesAsync(billingAccountName, customerName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates an Azure subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult BeginCreateSubscriptionInEnrollmentAccount(this ISubscriptionOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body) + { + return operations.BeginCreateSubscriptionInEnrollmentAccountAsync(enrollmentAccountName, body).GetAwaiter().GetResult(); + } + + /// + /// Creates an Azure subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the enrollment account to which the subscription will be + /// billed. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateSubscriptionInEnrollmentAccountAsync(this ISubscriptionOperations operations, string enrollmentAccountName, SubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateSubscriptionInEnrollmentAccountWithHttpMessagesAsync(enrollmentAccountName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create a new WebDirect or EA Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult BeginCreateSubscription(this ISubscriptionOperations operations, string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body) { - return operations.ListAsync().GetAwaiter().GetResult(); + return operations.BeginCreateSubscriptionAsync(billingAccountName, billingProfileName, invoiceSectionName, body).GetAwaiter().GetResult(); } /// - /// Lists all of the available pending Microsoft.Subscription API operations. + /// The operation to create a new WebDirect or EA Azure subscription. /// /// /// The operations group for this extension method. /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the billing profile in the billing account for which you want + /// to create the subscription. + /// + /// + /// The name of the invoice section in the billing account for which you want + /// to create the subscription. + /// + /// + /// The subscription creation parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateSubscriptionAsync(this ISubscriptionOperations operations, string billingAccountName, string billingProfileName, string invoiceSectionName, ModernSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateSubscriptionWithHttpMessagesAsync(billingAccountName, billingProfileName, invoiceSectionName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// + public static SubscriptionCreationResult BeginCreateCspSubscription(this ISubscriptionOperations operations, string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body) + { + return operations.BeginCreateCspSubscriptionAsync(billingAccountName, customerName, body).GetAwaiter().GetResult(); + } + + /// + /// The operation to create a new CSP subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Microsoft Customer Agreement billing account for which you + /// want to create the subscription. + /// + /// + /// The name of the customer. + /// + /// + /// The subscription creation parameters. + /// /// /// The cancellation token. /// - public static async Task ListAsync(this ISubscriptionOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task BeginCreateCspSubscriptionAsync(this ISubscriptionOperations operations, string billingAccountName, string customerName, ModernCspSubscriptionCreationParameters body, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + using (var _result = await operations.BeginCreateCspSubscriptionWithHttpMessagesAsync(billingAccountName, customerName, body, null, cancellationToken).ConfigureAwait(false)) { return _result.Body; } diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs deleted file mode 100644 index c5b50d71fd7a1..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperations.cs +++ /dev/null @@ -1,1296 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// SubscriptionsOperations operations. - /// - internal partial class SubscriptionsOperations : IServiceOperations, ISubscriptionsOperations - { - /// - /// Initializes a new instance of the SubscriptionsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal SubscriptionsOperations(SubscriptionClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SubscriptionClient - /// - public SubscriptionClient Client { get; private set; } - - /// - /// The operation to cancel a subscription - /// - /// - /// Subscription Id. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CancelWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (subscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); - } - string apiVersion = "2019-03-01-preview"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // 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; - } - - /// - /// The operation to rename a subscription - /// - /// - /// Subscription Id. - /// - /// - /// Subscription Name - /// - /// - /// 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> RenameWithHttpMessagesAsync(string subscriptionId, SubscriptionName body, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (subscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); - } - if (body == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "body"); - } - string apiVersion = "2019-03-01-preview"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("body", body); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Rename", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(body != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// The operation to enable a subscription - /// - /// - /// Subscription Id. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> EnableWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (subscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); - } - string apiVersion = "2019-03-01-preview"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Enable", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); - } - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - // 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 all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The ID of the target subscription. - /// - /// - /// 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>> ListLocationsWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (subscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); - } - string apiVersion = "2016-06-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListLocations", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/locations").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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 details about a specified subscription. - /// - /// - /// The ID of the target subscription. - /// - /// - /// 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 subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (subscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); - } - string apiVersion = "2016-06-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("subscriptionId", subscriptionId); - tracingParameters.Add("apiVersion", apiVersion); - 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}").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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 all subscriptions for a tenant. - /// - /// - /// 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 - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2016-06-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - 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").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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 all subscriptions for a tenant. - /// - /// - /// 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 HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs deleted file mode 100644 index c403fe1a5affd..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/SubscriptionsOperationsExtensions.cs +++ /dev/null @@ -1,275 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for SubscriptionsOperations. - /// - public static partial class SubscriptionsOperationsExtensions - { - /// - /// The operation to cancel a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - public static CanceledSubscriptionId Cancel(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.CancelAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// The operation to cancel a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - /// - /// The cancellation token. - /// - public static async Task CancelAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CancelWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The operation to rename a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - /// - /// Subscription Name - /// - public static RenamedSubscriptionId Rename(this ISubscriptionsOperations operations, string subscriptionId, SubscriptionName body) - { - return operations.RenameAsync(subscriptionId, body).GetAwaiter().GetResult(); - } - - /// - /// The operation to rename a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - /// - /// Subscription Name - /// - /// - /// The cancellation token. - /// - public static async Task RenameAsync(this ISubscriptionsOperations operations, string subscriptionId, SubscriptionName body, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.RenameWithHttpMessagesAsync(subscriptionId, body, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The operation to enable a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - public static EnabledSubscriptionId Enable(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.EnableAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// The operation to enable a subscription - /// - /// - /// The operations group for this extension method. - /// - /// - /// Subscription Id. - /// - /// - /// The cancellation token. - /// - public static async Task EnableAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.EnableWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - public static IEnumerable ListLocations(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.ListLocationsAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// Gets all available geo-locations. - /// - /// - /// This operation provides all the locations that are available for resource - /// providers; however, each resource provider may support a subset of this - /// list. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - /// - /// The cancellation token. - /// - public static async Task> ListLocationsAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListLocationsWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets details about a specified subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - public static SubscriptionModel Get(this ISubscriptionsOperations operations, string subscriptionId) - { - return operations.GetAsync(subscriptionId).GetAwaiter().GetResult(); - } - - /// - /// Gets details about a specified subscription. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The ID of the target subscription. - /// - /// - /// The cancellation token. - /// - public static async Task GetAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.GetWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this ISubscriptionsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ISubscriptionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ISubscriptionsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets all subscriptions for a tenant. - /// - /// - /// 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 ISubscriptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs deleted file mode 100644 index 69509b6381d6f..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperations.cs +++ /dev/null @@ -1,392 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// TenantsOperations operations. - /// - internal partial class TenantsOperations : IServiceOperations, ITenantsOperations - { - /// - /// Initializes a new instance of the TenantsOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal TenantsOperations(SubscriptionClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the SubscriptionClient - /// - public SubscriptionClient Client { get; private set; } - - /// - /// Gets the tenants for your account. - /// - /// - /// 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 - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - string apiVersion = "2016-06-01"; - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - 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("/") ? "" : "/")), "tenants").ToString(); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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 tenants for your account. - /// - /// - /// 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 HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - 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/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs b/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs deleted file mode 100644 index 36b8f3fbf0302..0000000000000 --- a/sdk/subscription/Microsoft.Azure.Management.Subscription/src/Generated/TenantsOperationsExtensions.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.Management.Subscription -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for TenantsOperations. - /// - public static partial class TenantsOperationsExtensions - { - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - public static IPage List(this ITenantsOperations operations) - { - return operations.ListAsync().GetAwaiter().GetResult(); - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this ITenantsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Gets the tenants for your account. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this ITenantsOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Gets the tenants for your account. - /// - /// - /// 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 ITenantsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -}