From ecaee494ff72e8b71c30774e08d8ee5b7097c4fc Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Fri, 10 May 2019 21:36:48 +0000 Subject: [PATCH] .NET SDK Resource Provider:'FabricAdmin' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5844' REST Spec PR Author 'cednation' REST Spec PR Last commit --- .../Generated/FabricLocationsOperations.cs | 202 +++++++++++++++ .../FabricLocationsOperationsExtensions.cs | 42 ++++ .../Generated/IFabricLocationsOperations.cs | 26 ++ .../Generated/IScaleUnitsOperations.cs | 60 ++++- .../CreateFromJsonScaleUnitParametersList.cs | 122 +++++++++ .../DeploymentJsonPhysicalNodeParameters.cs | 63 +++++ .../Models/NetworkDefinitionParameter.cs | 62 +++++ .../Generated/ScaleUnitsOperations.cs | 232 +++++++++++++++++- .../ScaleUnitsOperationsExtensions.cs | 106 +++++++- 9 files changed, 906 insertions(+), 9 deletions(-) create mode 100644 src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/CreateFromJsonScaleUnitParametersList.cs create mode 100644 src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/DeploymentJsonPhysicalNodeParameters.cs create mode 100644 src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/NetworkDefinitionParameter.cs diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperations.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperations.cs index 29e2e841c8d2..fb040269312d 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperations.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperations.cs @@ -446,6 +446,208 @@ internal FabricLocationsOperations(FabricAdminClient client) return _result; } + /// + /// Creates or updates a fabric location. This will fail if called outside + /// deployment. + /// + /// + /// Name of the resource group. + /// + /// + /// Fabric location object. + /// + /// + /// 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> CreateWithHttpMessagesAsync(string resourceGroupName, FabricLocation fabricObject, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (fabricObject == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "fabricObject"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("fabricObject", fabricObject); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + 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("PUT"); + _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(fabricObject != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(fabricObject, 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 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; + } + /// /// Returns a list of all fabric locations. /// diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperationsExtensions.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperationsExtensions.cs index 75648c7b7f3e..e1b965dd7740 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperationsExtensions.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/FabricLocationsOperationsExtensions.cs @@ -102,6 +102,48 @@ public static FabricLocation Get(this IFabricLocationsOperations operations, str } } + /// + /// Creates or updates a fabric location. This will fail if called outside + /// deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Fabric location object. + /// + public static FabricLocation Create(this IFabricLocationsOperations operations, string resourceGroupName, FabricLocation fabricObject) + { + return operations.CreateAsync(resourceGroupName, fabricObject).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a fabric location. This will fail if called outside + /// deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Fabric location object. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IFabricLocationsOperations operations, string resourceGroupName, FabricLocation fabricObject, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, fabricObject, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Returns a list of all fabric locations. /// diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IFabricLocationsOperations.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IFabricLocationsOperations.cs index c9d1a58bae27..6c04e23bf197 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IFabricLocationsOperations.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IFabricLocationsOperations.cs @@ -75,6 +75,32 @@ public partial interface IFabricLocationsOperations /// Task>> ListWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Creates or updates a fabric location. This will fail if called + /// outside deployment. + /// + /// + /// Name of the resource group. + /// + /// + /// Fabric location object. + /// + /// + /// 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> CreateWithHttpMessagesAsync(string resourceGroupName, FabricLocation fabricObject, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Returns a list of all fabric locations. /// /// diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IScaleUnitsOperations.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IScaleUnitsOperations.cs index 14c7f2618455..9f7f88b207b5 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IScaleUnitsOperations.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/IScaleUnitsOperations.cs @@ -25,7 +25,7 @@ namespace Microsoft.AzureStack.Management.Fabric.Admin public partial interface IScaleUnitsOperations { /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// Name of the resource group. @@ -54,6 +54,34 @@ public partial interface IScaleUnitsOperations /// Task ScaleOutWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, ScaleOutScaleUnitParametersList nodeList, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Add a new scale unit. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CreateFromJsonWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Returns the requested scale unit. /// /// @@ -110,7 +138,7 @@ public partial interface IScaleUnitsOperations /// Task>> ListWithHttpMessagesAsync(string resourceGroupName, string location, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// Name of the resource group. @@ -139,6 +167,34 @@ public partial interface IScaleUnitsOperations /// Task BeginScaleOutWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, ScaleOutScaleUnitParametersList nodeList, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Add a new scale unit. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginCreateFromJsonWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Returns a list of all scale units at a location. /// /// diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/CreateFromJsonScaleUnitParametersList.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/CreateFromJsonScaleUnitParametersList.cs new file mode 100644 index 000000000000..c6b4dcdddad0 --- /dev/null +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/CreateFromJsonScaleUnitParametersList.cs @@ -0,0 +1,122 @@ +// +// 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.AzureStack.Management.Fabric.Admin.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of input data that allows for creating the new scale unit. + /// + public partial class CreateFromJsonScaleUnitParametersList + { + /// + /// Initializes a new instance of the + /// CreateFromJsonScaleUnitParametersList class. + /// + public CreateFromJsonScaleUnitParametersList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CreateFromJsonScaleUnitParametersList class. + /// + /// Cluster name for the new scale + /// unit. + /// List of nodes in the scale + /// unit. + /// The ASN for the cluster's rack + /// TOR. + /// The software ASN for the cluster's + /// rack. + /// The list of IP addresses used for + /// TOR communication. + /// The information associated with + /// the infrastructure network that will be subdivided into + /// subnets. + /// The information associated with the + /// storage network that will be subdivided into subnets. + /// The network QOS priority + /// setting. + public CreateFromJsonScaleUnitParametersList(string clusterName = default(string), IList physicalNodes = default(IList), string torSwitchBgpAsn = default(string), string softwareBgpAsn = default(string), IList torSwitchBgpPeerIp = default(IList), NetworkDefinitionParameter infrastructureNetwork = default(NetworkDefinitionParameter), NetworkDefinitionParameter storageNetwork = default(NetworkDefinitionParameter), int? netQosPriority = default(int?)) + { + ClusterName = clusterName; + PhysicalNodes = physicalNodes; + TorSwitchBgpAsn = torSwitchBgpAsn; + SoftwareBgpAsn = softwareBgpAsn; + TorSwitchBgpPeerIp = torSwitchBgpPeerIp; + InfrastructureNetwork = infrastructureNetwork; + StorageNetwork = storageNetwork; + NetQosPriority = netQosPriority; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cluster name for the new scale unit. + /// + [JsonProperty(PropertyName = "clusterName")] + public string ClusterName { get; set; } + + /// + /// Gets or sets list of nodes in the scale unit. + /// + [JsonProperty(PropertyName = "physicalNodes")] + public IList PhysicalNodes { get; set; } + + /// + /// Gets or sets the ASN for the cluster's rack TOR. + /// + [JsonProperty(PropertyName = "torSwitchBgpAsn")] + public string TorSwitchBgpAsn { get; set; } + + /// + /// Gets or sets the software ASN for the cluster's rack. + /// + [JsonProperty(PropertyName = "softwareBgpAsn")] + public string SoftwareBgpAsn { get; set; } + + /// + /// Gets or sets the list of IP addresses used for TOR communication. + /// + [JsonProperty(PropertyName = "torSwitchBgpPeerIp")] + public IList TorSwitchBgpPeerIp { get; set; } + + /// + /// Gets or sets the information associated with the infrastructure + /// network that will be subdivided into subnets. + /// + [JsonProperty(PropertyName = "infrastructureNetwork")] + public NetworkDefinitionParameter InfrastructureNetwork { get; set; } + + /// + /// Gets or sets the information associated with the storage network + /// that will be subdivided into subnets. + /// + [JsonProperty(PropertyName = "storageNetwork")] + public NetworkDefinitionParameter StorageNetwork { get; set; } + + /// + /// Gets or sets the network QOS priority setting. + /// + [JsonProperty(PropertyName = "netQosPriority")] + public int? NetQosPriority { get; set; } + + } +} diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/DeploymentJsonPhysicalNodeParameters.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/DeploymentJsonPhysicalNodeParameters.cs new file mode 100644 index 000000000000..7dba0c37a693 --- /dev/null +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/DeploymentJsonPhysicalNodeParameters.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.AzureStack.Management.Fabric.Admin.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Description of a bare metal node used for scale unit scale out + /// operations. + /// + public partial class DeploymentJsonPhysicalNodeParameters + { + /// + /// Initializes a new instance of the + /// DeploymentJsonPhysicalNodeParameters class. + /// + public DeploymentJsonPhysicalNodeParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DeploymentJsonPhysicalNodeParameters class. + /// + /// BMC address of the physical + /// machine. + /// Computer name of the physical machine. + public DeploymentJsonPhysicalNodeParameters(string bMCIPAddress = default(string), string name = default(string)) + { + BMCIPAddress = bMCIPAddress; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets BMC address of the physical machine. + /// + [JsonProperty(PropertyName = "bmcIpAddress")] + public string BMCIPAddress { get; set; } + + /// + /// Gets or sets computer name of the physical machine. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/NetworkDefinitionParameter.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/NetworkDefinitionParameter.cs new file mode 100644 index 000000000000..09951c93ab54 --- /dev/null +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/Models/NetworkDefinitionParameter.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.AzureStack.Management.Fabric.Admin.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A definition of the network received from a new cluster operation. + /// + public partial class NetworkDefinitionParameter + { + /// + /// Initializes a new instance of the NetworkDefinitionParameter class. + /// + public NetworkDefinitionParameter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkDefinitionParameter class. + /// + /// The subnet IP mask in the example format + /// 10.0.0.0/25. + /// The Vlan ID of the subnet. + public NetworkDefinitionParameter(IList subnet = default(IList), IList vlanId = default(IList)) + { + Subnet = subnet; + VlanId = vlanId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the subnet IP mask in the example format 10.0.0.0/25. + /// + [JsonProperty(PropertyName = "subnet")] + public IList Subnet { get; set; } + + /// + /// Gets or sets the Vlan ID of the subnet. + /// + [JsonProperty(PropertyName = "vlanId")] + public IList VlanId { get; set; } + + } +} diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperations.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperations.cs index 36de594aff87..1d15a72bfe43 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperations.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperations.cs @@ -52,7 +52,7 @@ internal ScaleUnitsOperations(FabricAdminClient client) public FabricAdminClient Client { get; private set; } /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// Name of the resource group. @@ -79,6 +79,34 @@ internal ScaleUnitsOperations(FabricAdminClient client) return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } + /// + /// Add a new scale unit. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task CreateFromJsonWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateFromJsonWithHttpMessagesAsync(resourceGroupName, location, scaleUnit, creationData, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + /// /// Returns the requested scale unit. /// @@ -493,7 +521,7 @@ internal ScaleUnitsOperations(FabricAdminClient client) } /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// Name of the resource group. @@ -567,7 +595,7 @@ internal ScaleUnitsOperations(FabricAdminClient client) } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/scaleUnits/{scaleUnit}/ScaleOut").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/scaleUnits/{scaleUnit}/scaleOut").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); @@ -690,6 +718,204 @@ internal ScaleUnitsOperations(FabricAdminClient client) return _result; } + /// + /// Add a new scale unit. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginCreateFromJsonWithHttpMessagesAsync(string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "location"); + } + if (scaleUnit == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scaleUnit"); + } + if (creationData == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "creationData"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("location", location); + tracingParameters.Add("scaleUnit", scaleUnit); + tracingParameters.Add("creationData", creationData); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateFromJson", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/scaleUnits/{scaleUnit}/createFromJson").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); + _url = _url.Replace("{scaleUnit}", System.Uri.EscapeDataString(scaleUnit)); + 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(creationData != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(creationData, 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 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Returns a list of all scale units at a location. /// diff --git a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperationsExtensions.cs b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperationsExtensions.cs index 071602e3534b..7292fe34ea1c 100644 --- a/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperationsExtensions.cs +++ b/src/AzureStack/Admin/FabricAdmin/Fabric.Admin/Generated/ScaleUnitsOperationsExtensions.cs @@ -23,7 +23,7 @@ namespace Microsoft.AzureStack.Management.Fabric.Admin public static partial class ScaleUnitsOperationsExtensions { /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// The operations group for this extension method. @@ -46,7 +46,7 @@ public static void ScaleOut(this IScaleUnitsOperations operations, string resour } /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// The operations group for this extension method. @@ -71,6 +71,55 @@ public static void ScaleOut(this IScaleUnitsOperations operations, string resour (await operations.ScaleOutWithHttpMessagesAsync(resourceGroupName, location, scaleUnit, nodeList, null, cancellationToken).ConfigureAwait(false)).Dispose(); } + /// + /// Add a new scale unit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + public static void CreateFromJson(this IScaleUnitsOperations operations, string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData) + { + operations.CreateFromJsonAsync(resourceGroupName, location, scaleUnit, creationData).GetAwaiter().GetResult(); + } + + /// + /// Add a new scale unit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// The cancellation token. + /// + public static async Task CreateFromJsonAsync(this IScaleUnitsOperations operations, string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CreateFromJsonWithHttpMessagesAsync(resourceGroupName, location, scaleUnit, creationData, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// Returns the requested scale unit. /// @@ -164,7 +213,7 @@ public static ScaleUnit Get(this IScaleUnitsOperations operations, string resour } /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// The operations group for this extension method. @@ -187,7 +236,7 @@ public static void BeginScaleOut(this IScaleUnitsOperations operations, string r } /// - /// Add a new scale unit. + /// Scales out a scale unit. /// /// /// The operations group for this extension method. @@ -212,6 +261,55 @@ public static void BeginScaleOut(this IScaleUnitsOperations operations, string r (await operations.BeginScaleOutWithHttpMessagesAsync(resourceGroupName, location, scaleUnit, nodeList, null, cancellationToken).ConfigureAwait(false)).Dispose(); } + /// + /// Add a new scale unit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + public static void BeginCreateFromJson(this IScaleUnitsOperations operations, string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData) + { + operations.BeginCreateFromJsonAsync(resourceGroupName, location, scaleUnit, creationData).GetAwaiter().GetResult(); + } + + /// + /// Add a new scale unit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the resource group. + /// + /// + /// Location of the resource. + /// + /// + /// Name of the scale units. + /// + /// + /// A list of input data that allows for creating the new scale unit. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateFromJsonAsync(this IScaleUnitsOperations operations, string resourceGroupName, string location, string scaleUnit, CreateFromJsonScaleUnitParametersList creationData, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginCreateFromJsonWithHttpMessagesAsync(resourceGroupName, location, scaleUnit, creationData, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// /// Returns a list of all scale units at a location. ///