diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs index 4fbbf9753dd07..47eefd0f4ab78 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs @@ -602,6 +602,28 @@ public void CustomNamedRequestIdTest() } } + [Fact] + public void CustomNamedRequestIdParameterGroupingTest() + { + SwaggerSpecRunner.RunTests( + SwaggerPath("azure-special-properties.json"), ExpectedPath("AzureSpecials"), generator: "Azure.CSharp"); + + const string validSubscription = "1234-5678-9012-3456"; + const string expectedRequestId = "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"; + + using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri, + new TokenCredentials(validSubscription, Guid.NewGuid().ToString()))) + { + var group = new HeaderCustomNamedRequestIdParamGroupingParameters() + { + FooClientRequestId = expectedRequestId + }; + IAzureOperationResponse response = client.Header.CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(group).Result; + + Assert.Equal("123", response.RequestId); + } + } + [Fact] public void DurationTests() { diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs index c229afd99c5ae..110100a8093ef 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs @@ -216,5 +216,172 @@ public async Task + /// Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the + /// header of the request, via a parameter group + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (headerCustomNamedRequestIdParamGroupingParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "headerCustomNamedRequestIdParamGroupingParameters"); + } + if (headerCustomNamedRequestIdParamGroupingParameters != null) + { + headerCustomNamedRequestIdParamGroupingParameters.Validate(); + } + string fooClientRequestId = default(string); + if (headerCustomNamedRequestIdParamGroupingParameters != null) + { + fooClientRequestId = headerCustomNamedRequestIdParamGroupingParameters.FooClientRequestId; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("fooClientRequestId", fooClientRequestId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CustomNamedRequestIdParamGrouping", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "azurespecials/customNamedRequestIdParamGrouping").ToString(); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("foo-client-request-id", Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (fooClientRequestId != null) + { + if (_httpRequest.Headers.Contains("foo-client-request-id")) + { + _httpRequest.Headers.Remove("foo-client-request-id"); + } + _httpRequest.Headers.TryAddWithoutValidation("foo-client-request-id", fooClientRequestId); + } + 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 (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.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 ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.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 AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("foo-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("foo-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(this.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/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperationsExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperationsExtensions.cs index def5edb87b184..1c232829308b7 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperationsExtensions.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperationsExtensions.cs @@ -58,5 +58,41 @@ public static async Task CustomNamedRequestId } } + /// + /// Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the + /// header of the request, via a parameter group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + public static HeaderCustomNamedRequestIdParamGroupingHeaders CustomNamedRequestIdParamGrouping(this IHeaderOperations operations, HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters) + { + return Task.Factory.StartNew(s => ((IHeaderOperations)s).CustomNamedRequestIdParamGroupingAsync(headerCustomNamedRequestIdParamGroupingParameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the + /// header of the request, via a parameter group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task CustomNamedRequestIdParamGroupingAsync(this IHeaderOperations operations, HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(headerCustomNamedRequestIdParamGroupingParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + } } diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/IHeaderOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/IHeaderOperations.cs index 47e4df834179b..6dc1bf8e0271a 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/IHeaderOperations.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/IHeaderOperations.cs @@ -42,5 +42,19 @@ public partial interface IHeaderOperations /// Thrown when a required parameter is null /// Task> CustomNamedRequestIdWithHttpMessagesAsync(string fooClientRequestId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 + /// in the header of the request, via a parameter group + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingHeaders.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingHeaders.cs new file mode 100644 index 0000000000000..edacca9832d0b --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingHeaders.cs @@ -0,0 +1,46 @@ +// 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 Fixtures.Azure.AcceptanceTestsAzureSpecials.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Microsoft.Rest.Azure; + + /// + /// Defines headers for customNamedRequestIdParamGrouping operation. + /// + public partial class HeaderCustomNamedRequestIdParamGroupingHeaders + { + /// + /// Initializes a new instance of the + /// HeaderCustomNamedRequestIdParamGroupingHeaders class. + /// + public HeaderCustomNamedRequestIdParamGroupingHeaders() { } + + /// + /// Initializes a new instance of the + /// HeaderCustomNamedRequestIdParamGroupingHeaders class. + /// + public HeaderCustomNamedRequestIdParamGroupingHeaders(string fooRequestId = default(string)) + { + FooRequestId = fooRequestId; + } + + /// + /// Gets or sets gets the foo-request-id. + /// + [JsonProperty(PropertyName = "foo-request-id")] + public string FooRequestId { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingParameters.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingParameters.cs new file mode 100644 index 0000000000000..9a44e5f9ceadd --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureSpecials/Models/HeaderCustomNamedRequestIdParamGroupingParameters.cs @@ -0,0 +1,57 @@ +// 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 Fixtures.Azure.AcceptanceTestsAzureSpecials.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Microsoft.Rest.Azure; + + /// + /// Additional parameters for the header_customNamedRequestIdParamGrouping + /// operation. + /// + public partial class HeaderCustomNamedRequestIdParamGroupingParameters + { + /// + /// Initializes a new instance of the + /// HeaderCustomNamedRequestIdParamGroupingParameters class. + /// + public HeaderCustomNamedRequestIdParamGroupingParameters() { } + + /// + /// Initializes a new instance of the + /// HeaderCustomNamedRequestIdParamGroupingParameters class. + /// + public HeaderCustomNamedRequestIdParamGroupingParameters(string fooClientRequestId) + { + FooClientRequestId = fooClientRequestId; + } + + /// + /// Gets or sets the fooRequestId + /// + [JsonProperty(PropertyName = "")] + public string FooClientRequestId { get; set; } + + /// + /// Validate the object. Throws ValidationException if validation fails. + /// + public virtual void Validate() + { + if (FooClientRequestId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "FooClientRequestId"); + } + } + } +} diff --git a/AutoRest/Generators/Extensions/Azure.Extensions/AzureExtensions.cs b/AutoRest/Generators/Extensions/Azure.Extensions/AzureExtensions.cs index d4863ccf8beb9..6898c3ec096ac 100644 --- a/AutoRest/Generators/Extensions/Azure.Extensions/AzureExtensions.cs +++ b/AutoRest/Generators/Extensions/Azure.Extensions/AzureExtensions.cs @@ -73,6 +73,7 @@ public static void NormalizeAzureClientModel(ServiceClient serviceClient, Settin // This extension from general extensions must be run prior to Azure specific extensions. ProcessParameterizedHost(serviceClient, settings); + ProcessClientRequestIdExtension(serviceClient); UpdateHeadMethods(serviceClient); ParseODataExtension(serviceClient); FlattenModels(serviceClient); @@ -492,34 +493,50 @@ private static Parameter CreateParameterFromGrouping(IEnumerable parameter.Extensions.ContainsKey(ClientRequestIdExtension)) + .Select(parameter => + { + bool? extensionObject = parameter.Extensions[ClientRequestIdExtension] as bool?; + if (extensionObject != null && extensionObject.Value) + { + return parameter.SerializedName; + } + return null; + }) + .SingleOrDefault(); + + string clientRequestIdName = customClientRequestIdName ?? defaultClientRequestIdName; + method.Extensions.Add(ClientRequestIdExtension, clientRequestIdName); + } + } + public static string GetClientRequestIdString(Method method) { if (method == null) { throw new ArgumentNullException("method"); } - - string clientRequestIdName = "x-ms-client-request-id"; - foreach (Parameter parameter in method.Parameters) + + if (method.Extensions.ContainsKey(ClientRequestIdExtension)) { - if (parameter.Extensions.ContainsKey(ClientRequestIdExtension)) - { - bool? extensionObject = parameter.Extensions[ClientRequestIdExtension] as bool?; - if (extensionObject != null) - { - bool useParamAsClientRequestId = extensionObject.Value; - if (useParamAsClientRequestId) - { - //TODO: Need to do something if they specify two ClientRequestIdExtensions for the same method...? - clientRequestIdName = parameter.SerializedName; - break; - } - } - } + return method.Extensions[ClientRequestIdExtension] as string; + } + else + { + throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Method missing expected {0} extension", ClientRequestIdExtension)); } - - return clientRequestIdName; } public static string GetRequestIdString(Method method) diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperations.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperations.java index 30a984ca2f048..2c188bbe53549 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperations.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperations.java @@ -15,6 +15,8 @@ import com.microsoft.rest.ServiceResponseWithHeaders; import fixtures.azurespecials.models.ErrorException; import fixtures.azurespecials.models.HeaderCustomNamedRequestIdHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingParameters; import java.io.IOException; /** @@ -43,4 +45,25 @@ public interface HeaderOperations { */ ServiceCall customNamedRequestIdAsync(String fooClientRequestId, final ServiceCallback serviceCallback) throws IllegalArgumentException; + /** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, via a parameter group. + * + * @param headerCustomNamedRequestIdParamGroupingParameters Additional parameters for the operation + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + ServiceResponseWithHeaders customNamedRequestIdParamGrouping(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters) throws ErrorException, IOException, IllegalArgumentException; + + /** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, via a parameter group. + * + * @param headerCustomNamedRequestIdParamGroupingParameters Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall customNamedRequestIdParamGroupingAsync(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, final ServiceCallback serviceCallback) throws IllegalArgumentException; + } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperationsImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperationsImpl.java index 7a14af1495a69..316d527ee4f87 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperationsImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/HeaderOperationsImpl.java @@ -16,8 +16,11 @@ import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.ServiceResponseWithHeaders; +import com.microsoft.rest.Validator; import fixtures.azurespecials.models.ErrorException; import fixtures.azurespecials.models.HeaderCustomNamedRequestIdHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingParameters; import java.io.IOException; import okhttp3.ResponseBody; import retrofit2.Call; @@ -57,6 +60,10 @@ interface HeaderService { @POST("azurespecials/customNamedRequestId") Call customNamedRequestId(@Header("foo-client-request-id") String fooClientRequestId, @Header("accept-language") String acceptLanguage); + @Headers("Content-Type: application/json; charset=utf-8") + @POST("azurespecials/customNamedRequestIdParamGrouping") + Call customNamedRequestIdParamGrouping(@Header("accept-language") String acceptLanguage, @Header("foo-client-request-id") String fooClientRequestId); + } /** @@ -114,4 +121,63 @@ private ServiceResponseWithHeaders cust .buildWithHeaders(response, HeaderCustomNamedRequestIdHeaders.class); } + /** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, via a parameter group. + * + * @param headerCustomNamedRequestIdParamGroupingParameters Additional parameters for the operation + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public ServiceResponseWithHeaders customNamedRequestIdParamGrouping(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters) throws ErrorException, IOException, IllegalArgumentException { + if (headerCustomNamedRequestIdParamGroupingParameters == null) { + throw new IllegalArgumentException("Parameter headerCustomNamedRequestIdParamGroupingParameters is required and cannot be null."); + } + Validator.validate(headerCustomNamedRequestIdParamGroupingParameters); + String fooClientRequestId = headerCustomNamedRequestIdParamGroupingParameters.getFooClientRequestId(); + Call call = service.customNamedRequestIdParamGrouping(this.client.getAcceptLanguage(), fooClientRequestId); + return customNamedRequestIdParamGroupingDelegate(call.execute()); + } + + /** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, via a parameter group. + * + * @param headerCustomNamedRequestIdParamGroupingParameters Additional parameters for the operation + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall customNamedRequestIdParamGroupingAsync(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (headerCustomNamedRequestIdParamGroupingParameters == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter headerCustomNamedRequestIdParamGroupingParameters is required and cannot be null.")); + return null; + } + Validator.validate(headerCustomNamedRequestIdParamGroupingParameters, serviceCallback); + String fooClientRequestId = headerCustomNamedRequestIdParamGroupingParameters.getFooClientRequestId(); + Call call = service.customNamedRequestIdParamGrouping(this.client.getAcceptLanguage(), fooClientRequestId); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(customNamedRequestIdParamGroupingDelegate(response)); + } catch (ErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponseWithHeaders customNamedRequestIdParamGroupingDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.getMapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .buildWithHeaders(response, HeaderCustomNamedRequestIdParamGroupingHeaders.class); + } + } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingHeaders.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingHeaders.java new file mode 100644 index 0000000000000..bd2f6562bd776 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingHeaders.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azurespecials.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines headers for customNamedRequestIdParamGrouping operation. + */ +public class HeaderCustomNamedRequestIdParamGroupingHeaders { + /** + * Gets the foo-request-id. + */ + @JsonProperty(value = "foo-request-id") + private String fooRequestId; + + /** + * Get the fooRequestId value. + * + * @return the fooRequestId value + */ + public String getFooRequestId() { + return this.fooRequestId; + } + + /** + * Set the fooRequestId value. + * + * @param fooRequestId the fooRequestId value to set + */ + public void setFooRequestId(String fooRequestId) { + this.fooRequestId = fooRequestId; + } + +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingParameters.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingParameters.java new file mode 100644 index 0000000000000..e24d784a3a57e --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/models/HeaderCustomNamedRequestIdParamGroupingParameters.java @@ -0,0 +1,44 @@ +/** + * 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. + */ + +package fixtures.azurespecials.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Additional parameters for the header_customNamedRequestIdParamGrouping + * operation. + */ +public class HeaderCustomNamedRequestIdParamGroupingParameters { + /** + * The fooRequestId. + */ + @JsonProperty(value = "", required = true) + private String fooClientRequestId; + + /** + * Get the fooClientRequestId value. + * + * @return the fooClientRequestId value + */ + public String getFooClientRequestId() { + return this.fooClientRequestId; + } + + /** + * Set the fooClientRequestId value. + * + * @param fooClientRequestId the fooClientRequestId value to set + */ + public void setFooClientRequestId(String fooClientRequestId) { + this.fooClientRequestId = fooClientRequestId; + } + +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java index a812da5cef95c..5362f829bbbb5 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java @@ -2,6 +2,8 @@ import com.microsoft.rest.ServiceResponseWithHeaders; import fixtures.azurespecials.models.HeaderCustomNamedRequestIdHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingHeaders; +import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingParameters; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -20,4 +22,13 @@ public void customNamedRequestId() throws Exception { Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("123", response.getHeaders().getFooRequestId()); } + + @Test + public void customNamedRequestIdParamGrouping() throws Exception { + HeaderCustomNamedRequestIdParamGroupingParameters group = new HeaderCustomNamedRequestIdParamGroupingParameters(); + group.setFooClientRequestId("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); + ServiceResponseWithHeaders response = client.getHeaderOperations().customNamedRequestIdParamGrouping(group); + Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals("123", response.getHeaders().getFooRequestId()); + } } diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureSpecialProperties.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureSpecialProperties.js index ae45b1a36108b..313ce9f7eb5b6 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureSpecialProperties.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureSpecialProperties.js @@ -194,6 +194,16 @@ describe('nodejs', function () { }); }); + it('should allow custom-named request-id headers to be used with parameter grouping', function (done) { + testClient.header.customNamedRequestIdParamGrouping({fooClientRequestId: "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"}, function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + should.not.exist(request.headers["x-ms-client-request-id"]); + should.equal(response.headers["foo-request-id"], "123"); + done(); + }); + }); + it('should support OData filter', function (done) { var options = { filter: "id gt 5 and name eq 'foo'", diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/headerCustomNamedRequestIdParamGroupingParameters.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/headerCustomNamedRequestIdParamGroupingParameters.js new file mode 100644 index 0000000000000..2b454284719d4 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/headerCustomNamedRequestIdParamGroupingParameters.js @@ -0,0 +1,49 @@ +/* + * 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. + */ + +'use strict'; + +/** + * @class + * Initializes a new instance of the HeaderCustomNamedRequestIdParamGroupingParameters class. + * @constructor + * Additional parameters for the header_customNamedRequestIdParamGrouping + * operation. + * @member {string} fooClientRequestId The fooRequestId + * + */ +function HeaderCustomNamedRequestIdParamGroupingParameters() { +} + +/** + * Defines the metadata of HeaderCustomNamedRequestIdParamGroupingParameters + * + * @returns {object} metadata of HeaderCustomNamedRequestIdParamGroupingParameters + * + */ +HeaderCustomNamedRequestIdParamGroupingParameters.prototype.mapper = function () { + return { + required: false, + type: { + name: 'Composite', + className: 'HeaderCustomNamedRequestIdParamGroupingParameters', + modelProperties: { + fooClientRequestId: { + required: true, + type: { + name: 'String' + } + } + } + } + }; +}; + +module.exports = HeaderCustomNamedRequestIdParamGroupingParameters; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.d.ts b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.d.ts index 105da48bee116..8f3a9cb6cebf7 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.d.ts +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.d.ts @@ -40,3 +40,16 @@ export interface OdataFilter { id?: number; name?: string; } + +/** + * @class + * Initializes a new instance of the HeaderCustomNamedRequestIdParamGroupingParameters class. + * @constructor + * Additional parameters for the header_customNamedRequestIdParamGrouping + * operation. + * @member {string} fooClientRequestId The fooRequestId + * + */ +export interface HeaderCustomNamedRequestIdParamGroupingParameters { + fooClientRequestId: string; +} diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.js index cc097cead412b..934bde9e84a1d 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/models/index.js @@ -20,3 +20,4 @@ exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; exports.ErrorModel = require('./errorModel'); exports.OdataFilter = require('./odataFilter'); +exports.HeaderCustomNamedRequestIdParamGroupingParameters = require('./headerCustomNamedRequestIdParamGroupingParameters'); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js index 56fd01e80b311..9951aefd711dd 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js @@ -147,5 +147,140 @@ Header.prototype.customNamedRequestId = function (fooClientRequestId, options, c }); }; +/** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the + * header of the request, via a parameter group + * + * @param {object} headerCustomNamedRequestIdParamGroupingParameters + * Additional parameters for the operation + * + * @param {string} + * [headerCustomNamedRequestIdParamGroupingParameters.fooClientRequestId] The + * fooRequestId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +Header.prototype.customNamedRequestIdParamGrouping = function (headerCustomNamedRequestIdParamGroupingParameters, options, callback) { + var client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (headerCustomNamedRequestIdParamGroupingParameters === null || headerCustomNamedRequestIdParamGroupingParameters === undefined) { + throw new Error('headerCustomNamedRequestIdParamGroupingParameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + var fooClientRequestId; + try { + if (headerCustomNamedRequestIdParamGroupingParameters !== null && headerCustomNamedRequestIdParamGroupingParameters !== undefined) + { + fooClientRequestId = headerCustomNamedRequestIdParamGroupingParameters.fooClientRequestId; + if (fooClientRequestId === null || fooClientRequestId === undefined || typeof fooClientRequestId.valueOf() !== 'string') { + throw new Error('fooClientRequestId cannot be null or undefined and it must be of type string.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = this.client.baseUri + + '//azurespecials/customNamedRequestIdParamGrouping'; + var queryParameters = []; + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + // trim all duplicate forward slashes in the url + var regex = /([^:]\/)\/+/gi; + requestUrl = requestUrl.replace(regex, '$1'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.headers = {}; + httpRequest.url = requestUrl; + // Set Headers + if (this.client.generateClientRequestId) { + httpRequest.headers['foo-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if (fooClientRequestId !== undefined && fooClientRequestId !== null) { + httpRequest.headers['foo-client-request-id'] = fooClientRequestId; + } + if(options) { + for(var headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, function (err, response, responseBody) { + if (err) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + var parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + var resultMapper = new client.models['ErrorModel']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = util.format('Error "%s" occurred in deserializing the responseBody ' + + '- "%s" for the default response.', defaultError.message, responseBody); + return callback(error); + } + return callback(error); + } + // Create Result + var result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +}; + module.exports = Header; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/index.d.ts b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/index.d.ts index 7d68c1363e55d..34bbc6fd49c5b 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/index.d.ts +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/index.d.ts @@ -537,4 +537,26 @@ export interface Header { */ customNamedRequestId(fooClientRequestId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; customNamedRequestId(fooClientRequestId: string, callback: ServiceCallback): void; + + /** + * Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the + * header of the request, via a parameter group + * + * @param {object} headerCustomNamedRequestIdParamGroupingParameters + * Additional parameters for the operation + * + * @param {string} + * [headerCustomNamedRequestIdParamGroupingParameters.fooClientRequestId] The + * fooRequestId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [callback] callback function; see ServiceCallback + * doc in ms-rest index.d.ts for details + */ + customNamedRequestIdParamGrouping(headerCustomNamedRequestIdParamGroupingParameters: models.HeaderCustomNamedRequestIdParamGroupingParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + customNamedRequestIdParamGrouping(headerCustomNamedRequestIdParamGroupingParameters: models.HeaderCustomNamedRequestIdParamGroupingParameters, callback: ServiceCallback): void; } diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py index 32b33bf21a195..92e016a304d19 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py @@ -50,7 +50,7 @@ from msrestazure.azure_exceptions import CloudError, CloudErrorData from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient - +from autorestazurespecialparameterstestclient import models class XmsRequestClientIdTests(unittest.TestCase): @@ -81,6 +81,18 @@ def test_custom_named_request_id(self): response = client.header.custom_named_request_id(expectedRequestId, raw=True) self.assertEqual("123", response.response.headers.get("foo-request-id")) + + def test_custom_named_request_id_param_grouping(self): + + validSubscription = '1234-5678-9012-3456' + expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0' + + cred = BasicTokenAuthentication({"access_token":123}) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") + + group = models.HeaderCustomNamedRequestIdParamGroupingParameters(foo_client_request_id=expectedRequestId) + response = client.header.custom_named_request_id_param_grouping(group, raw=True) + self.assertEqual("123", response.response.headers.get("foo-request-id")) def test_client_request_id_in_exception(self): validSubscription = '1234-5678-9012-3456' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py index dec4f136004f7..172a4349ff36c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py @@ -14,7 +14,9 @@ class FirstParameterGroup(Model): """ - Additional parameters for one or more operations + Additional parameters for a set of operations, such as: + parameterGrouping_postMultiParamGroups, + parameterGrouping_postSharedParameterGroupObject. :param header_one: :type header_one: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py index 4d4af238358bc..bccdfab25480f 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py @@ -14,7 +14,8 @@ class ParameterGroupingPostMultiParamGroupsSecondParamGroup(Model): """ - Additional parameters for one or more operations + Additional parameters for the parameterGrouping_postMultiParamGroups + operation. :param header_two: :type header_two: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py index 623b79fd0feee..a62313adf9a27 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py @@ -14,7 +14,7 @@ class ParameterGroupingPostOptionalParameters(Model): """ - Additional parameters for one or more operations + Additional parameters for the parameterGrouping_postOptional operation. :param custom_header: :type custom_header: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py index 109ebe5ad51e0..409f4ffcdcf26 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py @@ -14,7 +14,7 @@ class ParameterGroupingPostRequiredParameters(Model): """ - Additional parameters for one or more operations + Additional parameters for the parameterGrouping_postRequired operation. :param body: :type body: int diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/__init__.py index a27f773dca33c..d97197e4c2288 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/__init__.py @@ -11,8 +11,10 @@ from .error import Error, ErrorException from .odata_filter import OdataFilter +from .header_custom_named_request_id_param_grouping_parameters import HeaderCustomNamedRequestIdParamGroupingParameters __all__ = [ 'Error', 'ErrorException', 'OdataFilter', + 'HeaderCustomNamedRequestIdParamGroupingParameters', ] diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/header_custom_named_request_id_param_grouping_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/header_custom_named_request_id_param_grouping_parameters.py new file mode 100644 index 0000000000000..05a691ff6d641 --- /dev/null +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/header_custom_named_request_id_param_grouping_parameters.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class HeaderCustomNamedRequestIdParamGroupingParameters(Model): + """ + Additional parameters for the header_customNamedRequestIdParamGrouping + operation. + + :param foo_client_request_id: The fooRequestId + :type foo_client_request_id: str + """ + + _validation = { + 'foo_client_request_id': {'required': True}, + } + + def __init__(self, foo_client_request_id): + self.foo_client_request_id = foo_client_request_id diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py index 3900422185422..0ff192a54cd3c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py @@ -79,3 +79,58 @@ def custom_named_request_id( 'foo-request-id': 'str', }) return client_raw_response + + def custom_named_request_id_param_grouping( + self, header_custom_named_request_id_param_grouping_parameters, custom_headers=None, raw=False, **operation_config): + """ + Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in + the header of the request, via a parameter group + + :param header_custom_named_request_id_param_grouping_parameters: + Additional parameters for the operation + :type header_custom_named_request_id_param_grouping_parameters: + :class:`HeaderCustomNamedRequestIdParamGroupingParameters + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: None + :rtype: :class:`ClientRawResponse` + if raw=true + """ + foo_client_request_id = None + if header_custom_named_request_id_param_grouping_parameters is not None: + foo_client_request_id = header_custom_named_request_id_param_grouping_parameters.foo_client_request_id + + # Construct URL + url = '/azurespecials/customNamedRequestIdParamGrouping' + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['foo-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['foo-client-request-id'] = self._serialize.header("foo_client_request_id", foo_client_request_id, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'foo-request-id': 'str', + }) + return client_raw_response diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py index 4fcaf367d51bc..15ba71465cac8 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py @@ -14,7 +14,7 @@ class PagingGetMultiplePagesOptions(Model): """ - Additional parameters for one or more operations + Additional parameters for the Paging_getMultiplePages operation. :param maxresults: Sets the maximum number of items to return in the response. diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py index 48ed388233daf..23e7a887f274c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py @@ -14,7 +14,7 @@ class PagingGetMultiplePagesWithOffsetOptions(Model): """ - Additional parameters for one or more operations + Additional parameters for the Paging_getMultiplePagesWithOffset operation. :param maxresults: Sets the maximum number of items to return in the response. diff --git a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs index 2bc8932aa11fc..400b4b6747249 100644 --- a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs +++ b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs @@ -59,6 +59,7 @@ public override void NormalizeClientModel(ServiceClient serviceClient) { // Don't add pagable/longrunning method since we already handle ourself. Settings.AddCredentials = true; + AzureExtensions.ProcessClientRequestIdExtension(serviceClient); AzureExtensions.UpdateHeadMethods(serviceClient); AzureExtensions.ParseODataExtension(serviceClient); Extensions.FlattenModels(serviceClient); diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py index 3e66e6a883e48..ef30dd1f2d039 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py @@ -14,7 +14,7 @@ class FlattenParameterGroup(Model): """ - Additional parameters for one or more operations + Additional parameters for the putSimpleProductWithGrouping operation. :param name: Product name with value 'groupproduct' :type name: str diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb index e53daa0997abc..6ff29ac477499 100644 --- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb +++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb @@ -162,7 +162,9 @@ expect(result.request_id).to eq("123") end - it 'should allow custom-named request-id headers to be used' do + it 'should allow custom-named request-id headers to be used with parameter grouping' do + pending 'Ruby does not support parameter grouping yet' + fail result = @client.header.custom_named_request_id_async(@validClientId).value! expect(result.response.status).to eq(200) expect(result.request_id).to eq("123") diff --git a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs index 42c6686cc0869..d11067a9903af 100644 --- a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs +++ b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs @@ -55,6 +55,7 @@ public override string UsageInstructions public override void NormalizeClientModel(ServiceClient serviceClient) { Settings.AddCredentials = true; + AzureExtensions.ProcessClientRequestIdExtension(serviceClient); AzureExtensions.UpdateHeadMethods(serviceClient); AzureExtensions.ParseODataExtension(serviceClient); AzureExtensions.AddPageableMethod(serviceClient, CodeNamer); diff --git a/AutoRest/TestServer/server/routes/azureSpecials.js b/AutoRest/TestServer/server/routes/azureSpecials.js index f156e395863b3..305e4e20686cd 100644 --- a/AutoRest/TestServer/server/routes/azureSpecials.js +++ b/AutoRest/TestServer/server/routes/azureSpecials.js @@ -33,6 +33,7 @@ var specials = function (coverage) { coverage['AzureXmsRequestClientOverwriteViaParameter'] = 0; coverage['AzureXmsRequestClientIdNull'] = 0; coverage['AzureXmsCustomNamedRequestId'] = 0; + coverage['AzureXmsCustomNamedRequestIdParameterGroup'] = 0; coverage['AzureRequestClientIdInError'] = 0; coverage['AzureODataFilter'] = 0; @@ -229,6 +230,18 @@ var specials = function (coverage) { res.set(headers).status(200).end(); } }); + + router.post('/customNamedRequestIdParamGrouping', function (req, res, next) { + var headers = { + 'foo-request-id': '123' + }; + if (req.get("foo-client-request-id") !== '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0') { + utils.send400(res, next, "Header foo-client-request-id must be set to 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0."); + } else { + coverage['AzureXmsCustomNamedRequestIdParameterGroup']++; + res.set(headers).status(200).end(); + } + }); } specials.prototype.router = router; diff --git a/AutoRest/TestServer/swagger/azure-special-properties.json b/AutoRest/TestServer/swagger/azure-special-properties.json index 7bbf1bc48570c..1db04fe3dfedb 100644 --- a/AutoRest/TestServer/swagger/azure-special-properties.json +++ b/AutoRest/TestServer/swagger/azure-special-properties.json @@ -815,6 +815,45 @@ } } } + }, + "/azurespecials/customNamedRequestIdParamGrouping": { + "post": { + "operationId": "header_customNamedRequestIdParamGrouping", + "description": "Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request, via a parameter group", + "parameters": [ + { + "name": "foo-client-request-id", + "in": "header", + "required": true, + "type": "string", + "description": "The fooRequestId", + "x-ms-client-request-id": true, + "x-ms-parameter-grouping": { + } + } + ], + "tags": [ + "Header Operations" + ], + "x-ms-request-id": "foo-request-id", + "responses": { + "200": { + "headers": { + "foo-request-id": { + "description": "Gets the foo-request-id.", + "type": "string" + } + }, + "description": "Gets the foo-request-id" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } } }, "parameters": { diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/check_name_availability_result.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/check_name_availability_result.py index 1c7ee5c86a0b9..3534f13656809 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/check_name_availability_result.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/check_name_availability_result.py @@ -16,7 +16,8 @@ class CheckNameAvailabilityResult(Model): :param reason: Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. Possible values include: 'AccountNameInvalid', 'AlreadyExists' - :type reason: str + :type reason: str or :class:`Reason + ` :param message: Gets an error message explaining the Reason value in more detail. :type message: str diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties.py index 2259b66353acf..0e5ad1120ce92 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties.py @@ -11,11 +11,13 @@ class StorageAccountProperties(Model): :param provisioning_state: Gets the status of the storage account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded' - :type provisioning_state: str + :type provisioning_state: str or :class:`ProvisioningState + ` :param account_type: Gets the type of the storage account. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` :param primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue or table object.Note that StandardZRS and PremiumLRS accounts only return the blob endpoint. @@ -26,7 +28,8 @@ class StorageAccountProperties(Model): :param status_of_primary: Gets the status indicating whether the primary location of the storage account is available or unavailable. Possible values include: 'Available', 'Unavailable' - :type status_of_primary: str + :type status_of_primary: str or :class:`AccountStatus + ` :param last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if there has never @@ -41,7 +44,8 @@ class StorageAccountProperties(Model): secondary location of the storage account is available or unavailable. Only available if the accountType is StandardGRS or StandardRAGRS. Possible values include: 'Available', 'Unavailable' - :type status_of_secondary: str + :type status_of_secondary: str or :class:`AccountStatus + ` :param creation_time: Gets the creation date and time of the storage account in UTC. :type creation_time: datetime diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_create_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_create_parameters.py index b2d63195ed800..b228be46caa06 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_create_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_create_parameters.py @@ -11,7 +11,8 @@ class StorageAccountPropertiesCreateParameters(Model): :param account_type: Gets or sets the account type. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` """ _validation = { diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_update_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_update_parameters.py index a9a27ddebd2c1..93634e3813e4e 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_update_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_properties_update_parameters.py @@ -13,7 +13,8 @@ class StorageAccountPropertiesUpdateParameters(Model): other account types cannot be changed to StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` :param custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py index a22a532456d2c..14ad7ea189b99 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py @@ -12,7 +12,8 @@ class Usage(Model): :param unit: Gets the unit of measurement. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - :type unit: str + :type unit: str or :class:`UsageUnit + ` :param current_value: Gets the current count of the allocated resources in the subscription. :type current_value: int diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/storage_accounts_operations.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/storage_accounts_operations.py index ef19c00fbeeac..6541b9ffbb1ba 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/storage_accounts_operations.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/storage_accounts_operations.py @@ -28,7 +28,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def check_name_availability( - self, account_name, custom_headers={}, raw=False, **operation_config): + self, account_name, custom_headers=None, raw=False, **operation_config): """ Checks that account name is valid and is not in use. @@ -95,7 +95,7 @@ def check_name_availability( return deserialized def create( - self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): """ Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and @@ -157,10 +157,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -194,7 +195,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Deletes a storage account in Microsoft Azure. @@ -252,7 +253,7 @@ def delete( return client_raw_response def get_properties( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The @@ -319,7 +320,7 @@ def get_properties( return deserialized def update( - self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): """ Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added @@ -404,7 +405,7 @@ def update( return deserialized def list_keys( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Lists the access keys for the specified storage account. @@ -466,7 +467,7 @@ def list_keys( return deserialized def list( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for @@ -531,7 +532,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def list_by_resource_group( - self, resource_group_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, custom_headers=None, raw=False, **operation_config): """ Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys @@ -600,7 +601,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def regenerate_key( - self, resource_group_name, account_name, regenerate_key, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, regenerate_key, custom_headers=None, raw=False, **operation_config): """ Regenerates the access keys for the specified storage account. diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/usage_operations.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/usage_operations.py index f267a651cd626..971ae1adeb2c4 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/usage_operations.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/operations/usage_operations.py @@ -27,7 +27,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def list( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Gets the current usage count and the limit for the resources under the subscription. diff --git a/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py b/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py index ef020f9303a6c..327355d28938c 100644 --- a/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py +++ b/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py @@ -52,7 +52,7 @@ def __init__( def add_pet_using_byte_array( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Fake endpoint to test byte array in body parameter for adding a new pet to the store @@ -99,7 +99,7 @@ def add_pet_using_byte_array( return client_raw_response def add_pet( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Add a new pet to the store @@ -145,7 +145,7 @@ def add_pet( return client_raw_response def update_pet( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Update an existing pet @@ -191,7 +191,7 @@ def update_pet( return client_raw_response def find_pets_by_status( - self, status=None, custom_headers={}, raw=False, **operation_config): + self, status=None, custom_headers=None, raw=False, **operation_config): """ Finds Pets by status Multiple status values can be provided with comma seperated strings @@ -240,7 +240,7 @@ def find_pets_by_status( return deserialized def find_pets_by_tags( - self, tags=None, custom_headers={}, raw=False, **operation_config): + self, tags=None, custom_headers=None, raw=False, **operation_config): """ Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, @@ -290,7 +290,7 @@ def find_pets_by_tags( return deserialized def find_pets_with_byte_array( - self, pet_id, custom_headers={}, raw=False, **operation_config): + self, pet_id, custom_headers=None, raw=False, **operation_config): """ Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API @@ -342,7 +342,7 @@ def find_pets_with_byte_array( return deserialized def get_pet_by_id( - self, pet_id, custom_headers={}, raw=False, **operation_config): + self, pet_id, custom_headers=None, raw=False, **operation_config): """ Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API @@ -394,7 +394,7 @@ def get_pet_by_id( return deserialized def update_pet_with_form( - self, pet_id, name=None, status=None, custom_headers={}, raw=False, **operation_config): + self, pet_id, name=None, status=None, custom_headers=None, raw=False, **operation_config): """ Updates a pet in the store with form data @@ -448,7 +448,7 @@ def update_pet_with_form( return client_raw_response def delete_pet( - self, pet_id, api_key=None, custom_headers={}, raw=False, **operation_config): + self, pet_id, api_key=None, custom_headers=None, raw=False, **operation_config): """ Deletes a pet @@ -495,7 +495,7 @@ def delete_pet( return client_raw_response def upload_file( - self, pet_id, additional_metadata=None, file=None, custom_headers={}, raw=False, **operation_config): + self, pet_id, additional_metadata=None, file=None, custom_headers=None, raw=False, **operation_config): """ uploads an image @@ -549,7 +549,7 @@ def upload_file( return client_raw_response def get_inventory( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Returns pet inventories by status Returns a map of status codes to quantities @@ -594,7 +594,7 @@ def get_inventory( return deserialized def place_order( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Place an order for a pet @@ -647,7 +647,7 @@ def place_order( return deserialized def get_order_by_id( - self, order_id, custom_headers={}, raw=False, **operation_config): + self, order_id, custom_headers=None, raw=False, **operation_config): """ Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other @@ -699,7 +699,7 @@ def get_order_by_id( return deserialized def delete_order( - self, order_id, custom_headers={}, raw=False, **operation_config): + self, order_id, custom_headers=None, raw=False, **operation_config): """ Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above @@ -744,7 +744,7 @@ def delete_order( return client_raw_response def create_user( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Create user This can only be done by the logged in user. @@ -791,7 +791,7 @@ def create_user( return client_raw_response def create_users_with_array_input( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Creates list of users with given input array @@ -837,7 +837,7 @@ def create_users_with_array_input( return client_raw_response def create_users_with_list_input( - self, body=None, custom_headers={}, raw=False, **operation_config): + self, body=None, custom_headers=None, raw=False, **operation_config): """ Creates list of users with given input array @@ -883,7 +883,7 @@ def create_users_with_list_input( return client_raw_response def login_user( - self, username=None, password=None, custom_headers={}, raw=False, **operation_config): + self, username=None, password=None, custom_headers=None, raw=False, **operation_config): """ Logs user into the system @@ -935,7 +935,7 @@ def login_user( return deserialized def logout_user( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Logs out current logged in user session @@ -972,7 +972,7 @@ def logout_user( return client_raw_response def get_user_by_name( - self, username, custom_headers={}, raw=False, **operation_config): + self, username, custom_headers=None, raw=False, **operation_config): """ Get user by user name @@ -1023,7 +1023,7 @@ def get_user_by_name( return deserialized def update_user( - self, username, body=None, custom_headers={}, raw=False, **operation_config): + self, username, body=None, custom_headers=None, raw=False, **operation_config): """ Updated user This can only be done by the logged in user. @@ -1076,7 +1076,7 @@ def update_user( return client_raw_response def delete_user( - self, username, custom_headers={}, raw=False, **operation_config): + self, username, custom_headers=None, raw=False, **operation_config): """ Delete user This can only be done by the logged in user. diff --git a/Samples/petstore/Ruby/petstore/swagger_petstore.rb b/Samples/petstore/Ruby/petstore/swagger_petstore.rb index d1ebfee575938..4ac6a5390b335 100644 --- a/Samples/petstore/Ruby/petstore/swagger_petstore.rb +++ b/Samples/petstore/Ruby/petstore/swagger_petstore.rb @@ -499,7 +499,7 @@ def find_pets_with_byte_array_async(pet_id, custom_headers = nil) path_template = '/pet/{petId}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id.to_s}, + path_params: {'petId' => pet_id}, headers: request_headers.merge(custom_headers || {}) } @@ -587,7 +587,7 @@ def get_pet_by_id_async(pet_id, custom_headers = nil) path_template = '/pet/{petId}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id.to_s}, + path_params: {'petId' => pet_id}, headers: request_headers.merge(custom_headers || {}) } @@ -749,7 +749,7 @@ def delete_pet_async(pet_id, api_key = nil, custom_headers = nil) path_template = '/pet/{petId}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id.to_s}, + path_params: {'petId' => pet_id}, headers: request_headers.merge(custom_headers || {}) } @@ -824,7 +824,7 @@ def upload_file_async(pet_id, additional_metadata = nil, file = nil, custom_head path_template = '/pet/{petId}/uploadImage' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], - path_params: {'petId' => pet_id.to_s}, + path_params: {'petId' => pet_id}, headers: request_headers.merge(custom_headers || {}) }