From 6b8360de308a91706f08a648cb9256a7f968617c Mon Sep 17 00:00:00 2001 From: Xing Wu Date: Tue, 14 Jun 2016 11:58:17 -0700 Subject: [PATCH] Fix python code gen bug in handling "." in property name. (#1144) --- .../Azure.CSharp.Tests/AcceptanceTests.cs | 10 + .../AzureSpecials/HeaderOperations.cs | 6 + .../AzureSpecials/IHeaderOperations.cs | 6 + ...omNamedRequestIdParamGroupingParameters.cs | 5 +- .../Paging/IPagingOperations.cs | 50 +++ .../AcceptanceTests/Paging/Models/Page1.cs | 50 +++ .../PagingGetOdataMultiplePagesOptions.cs | 55 +++ .../Paging/PagingOperations.cs | 411 ++++++++++++++++++ .../Paging/PagingOperationsExtensions.cs | 86 ++++ .../Models/FlattenedProduct.cs | 2 +- .../fixtures/paging/PagingOperations.java | 88 ++++ .../fixtures/paging/PagingOperationsImpl.java | 300 +++++++++++++ .../fixtures/paging/models/PageImpl1.java | 55 +++ .../PagingGetOdataMultiplePagesOptions.java | 68 +++ .../java/fixtures/paging/PagingTests.java | 6 + .../Java/Azure.Java/AzureJavaCodeNamer.cs | 1 + .../AzureMethodTemplateModel.cs | 21 +- .../TypeModels/AzureResponseModel.cs | 11 +- .../models/FlattenedProduct.java | 2 +- .../AcceptanceTests/paging.js | 20 + .../AcceptanceTests/Paging/models/index.d.ts | 17 + .../AcceptanceTests/Paging/models/index.js | 2 + .../Paging/models/odataProductResult.js | 70 +++ .../pagingGetOdataMultiplePagesOptions.js | 60 +++ .../Paging/operations/index.d.ts | 57 +++ .../Paging/operations/paging.js | 350 +++++++++++++++ .../models/flattenedProduct.js | 2 +- .../AcceptanceTests/paging_tests.py | 6 + .../AzureBodyDuration/setup.py | 2 +- .../AzureParameterGrouping/setup.py | 2 +- .../AcceptanceTests/AzureReport/setup.py | 2 +- .../AcceptanceTests/AzureResource/setup.py | 2 +- .../AcceptanceTests/AzureSpecials/setup.py | 2 +- .../AcceptanceTests/CustomBaseUri/setup.py | 2 +- .../Expected/AcceptanceTests/Head/setup.py | 2 +- .../AcceptanceTests/HeadExceptions/setup.py | 2 +- .../Expected/AcceptanceTests/Lro/setup.py | 2 +- .../models/__init__.py | 4 + ...paging_get_odata_multiple_pages_options.py | 30 ++ .../models/product_paged1.py | 27 ++ .../operations/paging_operations.py | 79 ++++ .../Expected/AcceptanceTests/Paging/setup.py | 2 +- .../StorageManagementClient/setup.py | 2 +- .../models/check_name_availability_result.py | 2 +- .../storagemanagementclient/models/foo.py | 2 +- .../models/storage_account.py | 8 +- .../storage_account_create_parameters.py | 2 +- ...orage_account_regenerate_key_parameters.py | 2 +- .../storage_account_update_parameters.py | 2 +- .../storagemanagementclient/models/usage.py | 2 +- .../operations/storage_accounts_operations.py | 2 +- .../SubscriptionIdApiVersion/setup.py | 2 +- .../Azure.Python/AzurePythonCodeGenerator.cs | 62 ++- .../models/flattened_product.py | 2 +- .../Python/Python/PythonCodeNamer.cs | 4 + .../RspecTests/paging_spec.rb | 14 + .../TestServer/server/routes/model-flatten.js | 18 +- AutoRest/TestServer/server/routes/paging.js | 15 + .../TestServer/swagger/model-flattening.json | 2 +- AutoRest/TestServer/swagger/paging.json | 62 +++ .../StorageManagementClientExtensions.cs | 19 - .../Azure.Java/models/Resource.java | 105 ----- .../models/storageAccountListResult.js | 2 + .../Azure.NodeJS/models/usageListResult.js | 2 + Samples/azure-storage/Azure.Python/setup.py | 2 +- .../models/check_name_availability_result.py | 3 +- .../models/storage_account_properties.py | 8 +- ...ge_account_properties_create_parameters.py | 2 +- ...ge_account_properties_update_parameters.py | 2 +- .../storagemanagementclient/models/usage.py | 3 +- .../models/storage_account_list_result.rb | 9 + .../azure_storage/models/usage_list_result.rb | 9 + Samples/azure-storage/azure-storage.json | 6 + 73 files changed, 2165 insertions(+), 189 deletions(-) create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/Page1.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/PagingGetOdataMultiplePagesOptions.cs create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PageImpl1.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PagingGetOdataMultiplePagesOptions.java create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/odataProductResult.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/pagingGetOdataMultiplePagesOptions.js create mode 100644 AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_odata_multiple_pages_options.py create mode 100644 AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_paged1.py delete mode 100644 Samples/azure-storage/Azure.CSharp/StorageManagementClientExtensions.cs delete mode 100644 Samples/azure-storage/Azure.Java/models/Resource.java diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs index 47eefd0f4ab78..0b96cc856e4b6 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs @@ -384,6 +384,16 @@ public void PagingHappyPathTests() } Assert.Equal(10, count); + result = client.Paging.GetOdataMultiplePages(); + Assert.NotNull(result.NextPageLink); + count = 1; + while (result.NextPageLink != null) + { + result = client.Paging.GetOdataMultiplePagesNext(result.NextPageLink); + count++; + } + Assert.Equal(10, count); + var options = new Fixtures.Azure.AcceptanceTestsPaging.Models.PagingGetMultiplePagesWithOffsetOptions(); options.Offset = 100; result = client.Paging.GetMultiplePagesWithOffset(options, "client-id"); 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 110100a8093ef..fa7fe72c43fca 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 @@ -229,6 +229,12 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) /// /// The cancellation token. /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// /// /// A response object containing the response body and response 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 6dc1bf8e0271a..be699fd72691b 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 @@ -55,6 +55,12 @@ public partial interface IHeaderOperations /// /// The cancellation token. /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// Task> CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(HeaderCustomNamedRequestIdParamGroupingParameters headerCustomNamedRequestIdParamGroupingParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } 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 index 9a44e5f9ceadd..2952b0300dfd0 100644 --- 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 @@ -44,8 +44,11 @@ public HeaderCustomNamedRequestIdParamGroupingParameters(string fooClientRequest public string FooClientRequestId { get; set; } /// - /// Validate the object. Throws ValidationException if validation fails. + /// Validate the object. /// + /// + /// Thrown if validation fails + /// public virtual void Validate() { if (FooClientRequestId == null) diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/IPagingOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/IPagingOperations.cs index eda3c26bb239a..7598c33eb6268 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/IPagingOperations.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/IPagingOperations.cs @@ -61,6 +61,28 @@ public partial interface IPagingOperations /// Task>> GetMultiplePagesWithHttpMessagesAsync(string clientRequestId = default(string), PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions = default(PagingGetMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// A paging operation that includes a nextLink in odata format that + /// has 10 pages + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + Task>> GetOdataMultiplePagesWithHttpMessagesAsync(string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// A paging operation that includes a nextLink that has 10 pages /// /// @@ -219,6 +241,34 @@ public partial interface IPagingOperations /// Task>> GetMultiplePagesNextWithHttpMessagesAsync(string nextPageLink, string clientRequestId = default(string), PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions = default(PagingGetMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// A paging operation that includes a nextLink in odata format that + /// has 10 pages + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> GetOdataMultiplePagesNextWithHttpMessagesAsync(string nextPageLink, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// A paging operation that includes a nextLink that has 10 pages /// /// diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/Page1.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/Page1.cs new file mode 100644 index 0000000000000..f7531fed363f9 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/Page1.cs @@ -0,0 +1,50 @@ +// 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.AcceptanceTestsPaging.Models +{ + using System.Collections.Generic; + using System.Linq; + using Newtonsoft.Json; + using Microsoft.Rest.Azure; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("odata.nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("values")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return (Items == null) ? Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/PagingGetOdataMultiplePagesOptions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/PagingGetOdataMultiplePagesOptions.cs new file mode 100644 index 0000000000000..3231c36550e61 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/Models/PagingGetOdataMultiplePagesOptions.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsPaging.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 Paging_getOdataMultiplePages operation. + /// + public partial class PagingGetOdataMultiplePagesOptions + { + /// + /// Initializes a new instance of the + /// PagingGetOdataMultiplePagesOptions class. + /// + public PagingGetOdataMultiplePagesOptions() { } + + /// + /// Initializes a new instance of the + /// PagingGetOdataMultiplePagesOptions class. + /// + public PagingGetOdataMultiplePagesOptions(int? maxresults = default(int?), int? timeout = default(int?)) + { + Maxresults = maxresults; + Timeout = timeout; + } + + /// + /// Gets or sets sets the maximum number of items to return in the + /// response. + /// + [JsonProperty(PropertyName = "")] + public int? Maxresults { get; set; } + + /// + /// Gets or sets sets the maximum time that the server can spend + /// processing the request, in seconds. The default is 30 seconds. + /// + [JsonProperty(PropertyName = "")] + public int? Timeout { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs index 083ba13c534c5..af8de612deaf0 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs @@ -408,6 +408,206 @@ internal PagingOperations(AutoRestPagingTestService client) return _result; } + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetOdataMultiplePagesWithHttpMessagesAsync(string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + int? maxresults = default(int?); + if (pagingGetOdataMultiplePagesOptions != null) + { + maxresults = pagingGetOdataMultiplePagesOptions.Maxresults; + } + int? timeout = default(int?); + if (pagingGetOdataMultiplePagesOptions != null) + { + timeout = pagingGetOdataMultiplePagesOptions.Timeout; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("clientRequestId", clientRequestId); + tracingParameters.Add("maxresults", maxresults); + tracingParameters.Add("timeout", timeout); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOdataMultiplePages", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "paging/multiple/odata").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("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (clientRequestId != null) + { + if (_httpRequest.Headers.Contains("client-request-id")) + { + _httpRequest.Headers.Remove("client-request-id"); + } + _httpRequest.Headers.TryAddWithoutValidation("client-request-id", clientRequestId); + } + 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 (maxresults != null) + { + if (_httpRequest.Headers.Contains("maxresults")) + { + _httpRequest.Headers.Remove("maxresults"); + } + _httpRequest.Headers.TryAddWithoutValidation("maxresults", SafeJsonConvert.SerializeObject(maxresults, this.Client.SerializationSettings).Trim('"')); + } + if (timeout != null) + { + if (_httpRequest.Headers.Contains("timeout")) + { + _httpRequest.Headers.Remove("timeout"); + } + _httpRequest.Headers.TryAddWithoutValidation("timeout", SafeJsonConvert.SerializeObject(timeout, this.Client.SerializationSettings).Trim('"')); + } + 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.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 = SafeJsonConvert.DeserializeObject>(_responseContent, this.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; + } + /// /// A paging operation that includes a nextLink that has 10 pages /// @@ -1791,6 +1991,217 @@ internal PagingOperations(AutoRestPagingTestService client) return _result; } + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetOdataMultiplePagesNextWithHttpMessagesAsync(string nextPageLink, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + int? maxresults = default(int?); + if (pagingGetOdataMultiplePagesOptions != null) + { + maxresults = pagingGetOdataMultiplePagesOptions.Maxresults; + } + int? timeout = default(int?); + if (pagingGetOdataMultiplePagesOptions != null) + { + timeout = pagingGetOdataMultiplePagesOptions.Timeout; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("clientRequestId", clientRequestId); + tracingParameters.Add("maxresults", maxresults); + tracingParameters.Add("timeout", timeout); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOdataMultiplePagesNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + 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("GET"); + _httpRequest.RequestUri = new Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + } + if (clientRequestId != null) + { + if (_httpRequest.Headers.Contains("client-request-id")) + { + _httpRequest.Headers.Remove("client-request-id"); + } + _httpRequest.Headers.TryAddWithoutValidation("client-request-id", clientRequestId); + } + 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 (maxresults != null) + { + if (_httpRequest.Headers.Contains("maxresults")) + { + _httpRequest.Headers.Remove("maxresults"); + } + _httpRequest.Headers.TryAddWithoutValidation("maxresults", SafeJsonConvert.SerializeObject(maxresults, this.Client.SerializationSettings).Trim('"')); + } + if (timeout != null) + { + if (_httpRequest.Headers.Contains("timeout")) + { + _httpRequest.Headers.Remove("timeout"); + } + _httpRequest.Headers.TryAddWithoutValidation("timeout", SafeJsonConvert.SerializeObject(timeout, this.Client.SerializationSettings).Trim('"')); + } + 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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.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 = SafeJsonConvert.DeserializeObject>(_responseContent, this.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; + } + /// /// A paging operation that includes a nextLink that has 10 pages /// diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperationsExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperationsExtensions.cs index 350809c93d122..ffd23b3181b5b 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperationsExtensions.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/Paging/PagingOperationsExtensions.cs @@ -88,6 +88,46 @@ public static IPage GetSinglePages(this IPagingOperations operations) } } + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + public static IPage GetOdataMultiplePages(this IPagingOperations operations, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions)) + { + return Task.Factory.StartNew(s => ((IPagingOperations)s).GetOdataMultiplePagesAsync(clientRequestId, pagingGetOdataMultiplePagesOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// The operations group for this extension method. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task> GetOdataMultiplePagesAsync(this IPagingOperations operations, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOdataMultiplePagesWithHttpMessagesAsync(clientRequestId, pagingGetOdataMultiplePagesOptions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// A paging operation that includes a nextLink that has 10 pages /// @@ -350,6 +390,52 @@ public static IPage GetSinglePagesNext(this IPagingOperations operation } } + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + public static IPage GetOdataMultiplePagesNext(this IPagingOperations operations, string nextPageLink, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions)) + { + return Task.Factory.StartNew(s => ((IPagingOperations)s).GetOdataMultiplePagesNextAsync(nextPageLink, clientRequestId, pagingGetOdataMultiplePagesOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// A paging operation that includes a nextLink in odata format that has 10 + /// pages + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task> GetOdataMultiplePagesNextAsync(this IPagingOperations operations, string nextPageLink, string clientRequestId = default(string), PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = default(PagingGetOdataMultiplePagesOptions), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOdataMultiplePagesNextWithHttpMessagesAsync(nextPageLink, clientRequestId, pagingGetOdataMultiplePagesOptions, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// A paging operation that includes a nextLink that has 10 pages /// diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/Models/FlattenedProduct.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/Models/FlattenedProduct.cs index 415f53a6e3dfd..fcca7e2f9ffad 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/Models/FlattenedProduct.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/Models/FlattenedProduct.cs @@ -37,7 +37,7 @@ public FlattenedProduct() { } /// /// - [JsonProperty(PropertyName = "properties.pname")] + [JsonProperty(PropertyName = "properties.p\\.name")] public string Pname { get; set; } /// diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperations.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperations.java index cf95eb2f018e9..297900251adf6 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperations.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperations.java @@ -16,9 +16,11 @@ import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceResponse; import fixtures.paging.models.PageImpl; +import fixtures.paging.models.PageImpl1; import fixtures.paging.models.PagingGetMultiplePagesOptions; import fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions; import fixtures.paging.models.PagingGetMultiplePagesWithOffsetOptions; +import fixtures.paging.models.PagingGetOdataMultiplePagesOptions; import fixtures.paging.models.Product; import java.io.IOException; @@ -84,6 +86,45 @@ public interface PagingOperations { */ ServiceCall getMultiplePagesAsync(final String clientRequestId, final PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions, final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + ServiceResponse> getOdataMultiplePages() throws CloudException, IOException; + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall getOdataMultiplePagesAsync(final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + ServiceResponse> getOdataMultiplePages(final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) throws CloudException, IOException; + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions 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 getOdataMultiplePagesAsync(final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions, final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** * A paging operation that includes a nextLink that has 10 pages. * @@ -286,6 +327,53 @@ public interface PagingOperations { */ ServiceCall getMultiplePagesNextAsync(final String nextPageLink, final String clientRequestId, final PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + ServiceResponse> getOdataMultiplePagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException; + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall getOdataMultiplePagesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + ServiceResponse> getOdataMultiplePagesNext(final String nextPageLink, final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) throws CloudException, IOException, IllegalArgumentException; + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall getOdataMultiplePagesNextAsync(final String nextPageLink, final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException; + /** * A paging operation that includes a nextLink that has 10 pages. * diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperationsImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperationsImpl.java index cf41764797840..1dc01736a4803 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperationsImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/PagingOperationsImpl.java @@ -21,9 +21,11 @@ import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.Validator; import fixtures.paging.models.PageImpl; +import fixtures.paging.models.PageImpl1; import fixtures.paging.models.PagingGetMultiplePagesOptions; import fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions; import fixtures.paging.models.PagingGetMultiplePagesWithOffsetOptions; +import fixtures.paging.models.PagingGetOdataMultiplePagesOptions; import fixtures.paging.models.Product; import java.io.IOException; import java.util.List; @@ -71,6 +73,10 @@ interface PagingService { @GET("paging/multiple") Call getMultiplePages(@Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); + @Headers("Content-Type: application/json; charset=utf-8") + @GET("paging/multiple/odata") + Call getOdataMultiplePages(@Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); + @Headers("Content-Type: application/json; charset=utf-8") @GET("paging/multiple/withpath/{offset}") Call getMultiplePagesWithOffset(@Path("offset") int offset, @Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); @@ -103,6 +109,10 @@ interface PagingService { @GET Call getMultiplePagesNext(@Url String nextPageLink, @Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getOdataMultiplePagesNext(@Url String nextPageLink, @Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); + @Headers("Content-Type: application/json; charset=utf-8") @GET Call getMultiplePagesWithOffsetNext(@Url String nextPageLink, @Header("client-request-id") String clientRequestId, @Header("accept-language") String acceptLanguage, @Header("maxresults") Integer maxresults, @Header("timeout") Integer timeout); @@ -329,6 +339,147 @@ private ServiceResponse> getMultiplePagesDelegate(Response> getOdataMultiplePages() throws CloudException, IOException { + final String clientRequestId = null; + final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = null; + Integer maxresults = null; + Integer timeout = null; + Call call = service.getOdataMultiplePages(clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + ServiceResponse> response = getOdataMultiplePagesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws CloudException, IOException { + return getOdataMultiplePagesNext(nextPageLink, null, null).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @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 getOdataMultiplePagesAsync(final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + final String clientRequestId = null; + final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = null; + Integer maxresults = null; + Integer timeout = null; + Call call = service.getOdataMultiplePages(clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getOdataMultiplePagesDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getOdataMultiplePagesNextAsync(result.getBody().getNextPageLink(), null, null, serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getOdataMultiplePages(final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) throws CloudException, IOException { + Validator.validate(pagingGetOdataMultiplePagesOptions); + Integer maxresults = null; + if (pagingGetOdataMultiplePagesOptions != null) { + maxresults = pagingGetOdataMultiplePagesOptions.getMaxresults(); + } + Integer timeout = null; + if (pagingGetOdataMultiplePagesOptions != null) { + timeout = pagingGetOdataMultiplePagesOptions.getTimeout(); + } + Call call = service.getOdataMultiplePages(clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + ServiceResponse> response = getOdataMultiplePagesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws CloudException, IOException { + return getOdataMultiplePagesNext(nextPageLink, clientRequestId, pagingGetOdataMultiplePagesOptions).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions 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 getOdataMultiplePagesAsync(final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + Validator.validate(pagingGetOdataMultiplePagesOptions, serviceCallback); + Integer maxresults = null; + if (pagingGetOdataMultiplePagesOptions != null) { + maxresults = pagingGetOdataMultiplePagesOptions.getMaxresults(); + } + Integer timeout = null; + if (pagingGetOdataMultiplePagesOptions != null) { + timeout = pagingGetOdataMultiplePagesOptions.getTimeout(); + } + Call call = service.getOdataMultiplePages(clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getOdataMultiplePagesDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getOdataMultiplePagesNextAsync(result.getBody().getNextPageLink(), clientRequestId, pagingGetOdataMultiplePagesOptions, serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getOdataMultiplePagesDelegate(Response response) throws CloudException, IOException { + return new AzureServiceResponseBuilder, CloudException>(this.client.getMapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + /** * A paging operation that includes a nextLink that has 10 pages. * @@ -999,6 +1150,155 @@ private ServiceResponse> getMultiplePagesNextDelegate(Response .build(response); } + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getOdataMultiplePagesNext(final String nextPageLink) throws CloudException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + final String clientRequestId = null; + final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = null; + Integer maxresults = null; + Integer timeout = null; + Call call = service.getOdataMultiplePagesNext(nextPageLink, clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + return getOdataMultiplePagesNextDelegate(call.execute()); + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @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 getOdataMultiplePagesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + final String clientRequestId = null; + final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = null; + Integer maxresults = null; + Integer timeout = null; + Call call = service.getOdataMultiplePagesNext(nextPageLink, clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getOdataMultiplePagesNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getOdataMultiplePagesNextAsync(result.getBody().getNextPageLink(), null, null, serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @throws CloudException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<Product> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getOdataMultiplePagesNext(final String nextPageLink, final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions) throws CloudException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Validator.validate(pagingGetOdataMultiplePagesOptions); + Integer maxresults = null; + if (pagingGetOdataMultiplePagesOptions != null) { + maxresults = pagingGetOdataMultiplePagesOptions.getMaxresults(); + } + Integer timeout = null; + if (pagingGetOdataMultiplePagesOptions != null) { + timeout = pagingGetOdataMultiplePagesOptions.getTimeout(); + } + Call call = service.getOdataMultiplePagesNext(nextPageLink, clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + return getOdataMultiplePagesNextDelegate(call.execute()); + } + + /** + * A paging operation that includes a nextLink in odata format that has 10 pages. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param clientRequestId the String value + * @param pagingGetOdataMultiplePagesOptions Additional parameters for the operation + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @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 getOdataMultiplePagesNextAsync(final String nextPageLink, final String clientRequestId, final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + Validator.validate(pagingGetOdataMultiplePagesOptions, serviceCallback); + Integer maxresults = null; + if (pagingGetOdataMultiplePagesOptions != null) { + maxresults = pagingGetOdataMultiplePagesOptions.getMaxresults(); + } + Integer timeout = null; + if (pagingGetOdataMultiplePagesOptions != null) { + timeout = pagingGetOdataMultiplePagesOptions.getTimeout(); + } + Call call = service.getOdataMultiplePagesNext(nextPageLink, clientRequestId, this.client.getAcceptLanguage(), maxresults, timeout); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getOdataMultiplePagesNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getOdataMultiplePagesNextAsync(result.getBody().getNextPageLink(), clientRequestId, pagingGetOdataMultiplePagesOptions, serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (CloudException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getOdataMultiplePagesNextDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.getMapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + /** * A paging operation that includes a nextLink that has 10 pages. * diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PageImpl1.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PageImpl1.java new file mode 100644 index 0000000000000..36a6f23b9d5da --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PageImpl1.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.paging.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl1 implements Page { + /** + * The link to the next page. + */ + @JsonProperty("odata.nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("values") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String getNextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List getItems() { + return items; + } +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PagingGetOdataMultiplePagesOptions.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PagingGetOdataMultiplePagesOptions.java new file mode 100644 index 0000000000000..ecd41d0316b51 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/models/PagingGetOdataMultiplePagesOptions.java @@ -0,0 +1,68 @@ +/** + * 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.paging.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Additional parameters for the Paging_getOdataMultiplePages operation. + */ +public class PagingGetOdataMultiplePagesOptions { + /** + * Sets the maximum number of items to return in the response. + */ + @JsonProperty(value = "") + private Integer maxresults; + + /** + * Sets the maximum time that the server can spend processing the request, + * in seconds. The default is 30 seconds. + */ + @JsonProperty(value = "") + private Integer timeout; + + /** + * Get the maxresults value. + * + * @return the maxresults value + */ + public Integer getMaxresults() { + return this.maxresults; + } + + /** + * Set the maxresults value. + * + * @param maxresults the maxresults value to set + */ + public void setMaxresults(Integer maxresults) { + this.maxresults = maxresults; + } + + /** + * Get the timeout value. + * + * @return the timeout value + */ + public Integer getTimeout() { + return this.timeout; + } + + /** + * Set the timeout value. + * + * @param timeout the timeout value to set + */ + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/paging/PagingTests.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/paging/PagingTests.java index 94b16136d7d73..1d8a1b9ec098b 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/paging/PagingTests.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/paging/PagingTests.java @@ -57,6 +57,12 @@ public void getMultiplePages() throws Exception { Assert.assertEquals(4, response.indexOf(p4)); } + @Test + public void getOdataMultiplePages() throws Exception { + List response = client.getPagingOperations().getOdataMultiplePages().getBody(); + Assert.assertEquals(10, response.size()); + } + @Test public void getMultiplePagesWithOffset() throws Exception { PagingGetMultiplePagesWithOffsetOptions options = new PagingGetMultiplePagesWithOffsetOptions(); diff --git a/AutoRest/Generators/Java/Azure.Java/AzureJavaCodeNamer.cs b/AutoRest/Generators/Java/Azure.Java/AzureJavaCodeNamer.cs index 9f73d3f513ea3..6051c60ba5672 100644 --- a/AutoRest/Generators/Java/Azure.Java/AzureJavaCodeNamer.cs +++ b/AutoRest/Generators/Java/Azure.Java/AzureJavaCodeNamer.cs @@ -50,6 +50,7 @@ private static string GetPagingSetting(Dictionary extensions, ID } pageClasses.Add(keypair, className); } + ext["className"] = pageClasses[keypair]; return pageClasses[keypair]; } diff --git a/AutoRest/Generators/Java/Azure.Java/TemplateModels/AzureMethodTemplateModel.cs b/AutoRest/Generators/Java/Azure.Java/TemplateModels/AzureMethodTemplateModel.cs index 993bb1f56af6a..6a295aa2123e8 100644 --- a/AutoRest/Generators/Java/Azure.Java/TemplateModels/AzureMethodTemplateModel.cs +++ b/AutoRest/Generators/Java/Azure.Java/TemplateModels/AzureMethodTemplateModel.cs @@ -18,6 +18,7 @@ public class AzureMethodTemplateModel : MethodTemplateModel { private AzureResponseModel _returnTypeModel; private Dictionary _responseModels; + private string pageClassName; public AzureMethodTemplateModel(Method source, ServiceClient serviceClient) : base(source, serviceClient) @@ -32,6 +33,12 @@ public AzureMethodTemplateModel(Method source, ServiceClient serviceClient) _returnTypeModel = new AzureResponseModel(ReturnType, this); _responseModels = new Dictionary(); Responses.ForEach(r => _responseModels.Add(r.Key, new AzureResponseModel(r.Value, this))); + + if (this.IsPagingOperation || this.IsPagingNextOperation) + { + var ext = this.Extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer; + pageClassName = (string)ext["className"] ?? "PageImpl"; + } } public string ClientRequestIdString { get; private set; } @@ -336,8 +343,8 @@ public override string ResponseGeneration(bool filterRequired = false) else if (this.IsPagingNonPollingOperation) { var builder = new IndentedStringBuilder(); - builder.AppendLine("{0}> response = {2}Delegate(call.execute());", - ReturnTypeModel.ClientResponseType, ((SequenceType)ReturnType.Body).ElementType.Name, this.Name.ToCamelCase()); + builder.AppendLine("{0}<{3}<{1}>> response = {2}Delegate(call.execute());", + ReturnTypeModel.ClientResponseType, ((SequenceType)ReturnType.Body).ElementType.Name, this.Name.ToCamelCase(), pageClassName); builder.AppendLine("{0} result = response.getBody().getItems();", this.ReturnType.Body.Name); return builder.ToString(); } @@ -426,8 +433,8 @@ public override string SuccessCallback(bool filterRequired = false) else if (this.IsPagingNonPollingOperation) { var builder = new IndentedStringBuilder(); - builder.AppendLine("{0}> result = {2}Delegate(response);", - ReturnTypeModel.ClientResponseType, ((SequenceType)ReturnType.Body).ElementType.Name, this.Name.ToCamelCase()); + builder.AppendLine("{0}<{3}<{1}>> result = {2}Delegate(response);", + ReturnTypeModel.ClientResponseType, ((SequenceType)ReturnType.Body).ElementType.Name, this.Name.ToCamelCase(), pageClassName); if (ReturnType.Headers == null) { builder.AppendLine("serviceCallback.success(new {0}<>(result.getBody().getItems(), result.getResponse()));", ReturnTypeModel.ClientResponseType); @@ -551,7 +558,7 @@ public override List InterfaceImports imports.Add("com.microsoft.azure.ListOperationCallback"); imports.Add("com.microsoft.azure.PagedList"); imports.Remove("java.util.List"); - imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = "PageImpl" }.ImportSafe()); + imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = pageClassName }.ImportSafe()); } return imports; } @@ -581,7 +588,7 @@ public override List ImplImports imports.Add("com.microsoft.azure.ListOperationCallback"); imports.Add("com.microsoft.azure.Page"); imports.Add("com.microsoft.azure.PagedList"); - imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = "PageImpl" }.ImportSafe()); + imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = pageClassName }.ImportSafe()); } if (this.IsPagingNextOperation) { @@ -590,7 +597,7 @@ public override List ImplImports } if (this.IsPagingNonPollingOperation) { - imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = "PageImpl" }.ImportSafe()); + imports.AddRange(new CompositeTypeModel(ServiceClient.Namespace) { Name = pageClassName }.ImportSafe()); } return imports; } diff --git a/AutoRest/Generators/Java/Azure.Java/TypeModels/AzureResponseModel.cs b/AutoRest/Generators/Java/Azure.Java/TypeModels/AzureResponseModel.cs index 9195830021b21..499ac74333e80 100644 --- a/AutoRest/Generators/Java/Azure.Java/TypeModels/AzureResponseModel.cs +++ b/AutoRest/Generators/Java/Azure.Java/TypeModels/AzureResponseModel.cs @@ -1,4 +1,5 @@ -using Microsoft.Rest.Generator.ClientModel; +using Microsoft.Rest.Generator.Azure; +using Microsoft.Rest.Generator.ClientModel; using System; using System.Collections.Generic; using System.Linq; @@ -32,7 +33,9 @@ public override string GenericBodyClientTypeString { if (BodyClientType is SequenceType && _method.IsPagingNextOperation) { - return string.Format(CultureInfo.InvariantCulture, "PageImpl<{0}>", ((SequenceType)BodyClientType).ElementType); + var ext = _method.Extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer; + string pageClassName = (string)ext["className"]; + return string.Format(CultureInfo.InvariantCulture, "{0}<{1}>", pageClassName, ((SequenceType)BodyClientType).ElementType); } else if (BodyClientType is SequenceType && _method.IsPagingOperation) { @@ -49,7 +52,9 @@ public override string GenericBodyWireTypeString SequenceTypeModel sequenceType = BodyWireType as SequenceTypeModel; if (sequenceType != null && (_method.IsPagingOperation || _method.IsPagingNextOperation || _method.IsPagingNonPollingOperation)) { - return string.Format(CultureInfo.InvariantCulture, "PageImpl<{0}>", sequenceType.ElementTypeModel.InstanceType()); + var ext = _method.Extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer; + string pageClassName = (string)ext["className"]; + return string.Format(CultureInfo.InvariantCulture, "{0}<{1}>", pageClassName, sequenceType.ElementTypeModel.InstanceType()); } return base.GenericBodyWireTypeString; } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/modelflattening/models/FlattenedProduct.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/modelflattening/models/FlattenedProduct.java index 12000dd404c20..4ecc3dcda947c 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/modelflattening/models/FlattenedProduct.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/modelflattening/models/FlattenedProduct.java @@ -21,7 +21,7 @@ public class FlattenedProduct extends Resource { /** * The pname property. */ - @JsonProperty(value = "properties.pname") + @JsonProperty(value = "properties.p\\.name") private String pname; /** diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/paging.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/paging.js index 414c3a95a5b24..41824827abfc6 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/paging.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/paging.js @@ -57,6 +57,26 @@ describe('nodejs', function () { }); }); + it('should get multiple pages with odata kind nextLink', function (done) { + testClient.paging.getOdataMultiplePages({ 'clientRequestId': 'client-id', 'pagingGetOdataMultiplePagesOptions': null }, function (error, result) { + var loop = function (nextLink, count) { + if (nextLink !== null && nextLink !== undefined) { + testClient.paging.getOdataMultiplePagesNext(nextLink, { 'clientRequestId': 'client-id', 'pagingGetOdataMultiplePagesOptions': null }, function (err, res) { + should.not.exist(err); + loop(res.odatanextLink, count + 1); + }); + } else { + count.should.be.exactly(10); + done(); + } + }; + + should.not.exist(error); + should.exist(result.odatanextLink); + loop(result.odatanextLink, 1); + }); + }); + it('should get multiple pages with offset', function (done) { testClient.paging.getMultiplePagesWithOffset({'offset': 100}, {'clientRequestId': 'client-id'}, function (error, result) { var loop = function (nextLink, count) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.d.ts b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.d.ts index 4df2fb2dc1100..41152f755a1c1 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.d.ts +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.d.ts @@ -69,6 +69,23 @@ export interface PagingGetMultiplePagesOptions { timeout?: number; } +/** + * @class + * Initializes a new instance of the PagingGetOdataMultiplePagesOptions class. + * @constructor + * Additional parameters for the Paging_getOdataMultiplePages operation. + * @member {number} [maxresults] Sets the maximum number of items to return in + * the response. + * + * @member {number} [timeout] Sets the maximum time that the server can spend + * processing the request, in seconds. The default is 30 seconds. + * + */ +export interface PagingGetOdataMultiplePagesOptions { + maxresults?: number; + timeout?: number; +} + /** * @class * Initializes a new instance of the PagingGetMultiplePagesWithOffsetOptions class. diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.js index 1f05fc5de873d..a815abfce75ed 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/index.js @@ -22,6 +22,8 @@ exports.Product = require('./product'); exports.ProductProperties = require('./productProperties'); exports.OperationResult = require('./operationResult'); exports.PagingGetMultiplePagesOptions = require('./pagingGetMultiplePagesOptions'); +exports.PagingGetOdataMultiplePagesOptions = require('./pagingGetOdataMultiplePagesOptions'); exports.PagingGetMultiplePagesWithOffsetOptions = require('./pagingGetMultiplePagesWithOffsetOptions'); exports.PagingGetMultiplePagesWithOffsetNextOptions = require('./pagingGetMultiplePagesWithOffsetNextOptions'); exports.ProductResult = require('./productResult'); +exports.OdataProductResult = require('./odataProductResult'); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/odataProductResult.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/odataProductResult.js new file mode 100644 index 0000000000000..8a33c07143689 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/odataProductResult.js @@ -0,0 +1,70 @@ +/* + * 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'; + +var util = require('util'); + +/** + * @class + * Initializes a new instance of the OdataProductResult class. + * @constructor + * @member {array} [values] + * + * @member {string} [odatanextLink] + * + */ +function OdataProductResult() { +} + +util.inherits(OdataProductResult, Array); + +/** + * Defines the metadata of OdataProductResult + * + * @returns {object} metadata of OdataProductResult + * + */ +OdataProductResult.prototype.mapper = function () { + return { + required: false, + serializedName: 'OdataProductResult', + type: { + name: 'Composite', + className: 'OdataProductResult', + modelProperties: { + values: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ProductElementType', + type: { + name: 'Composite', + className: 'Product' + } + } + } + }, + odatanextLink: { + required: false, + serializedName: 'odata\\.nextLink', + type: { + name: 'String' + } + } + } + } + }; +}; + +module.exports = OdataProductResult; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/pagingGetOdataMultiplePagesOptions.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/pagingGetOdataMultiplePagesOptions.js new file mode 100644 index 0000000000000..d66d9dddf64f0 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/models/pagingGetOdataMultiplePagesOptions.js @@ -0,0 +1,60 @@ +/* + * 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 PagingGetOdataMultiplePagesOptions class. + * @constructor + * Additional parameters for the Paging_getOdataMultiplePages operation. + * @member {number} [maxresults] Sets the maximum number of items to return in + * the response. + * + * @member {number} [timeout] Sets the maximum time that the server can spend + * processing the request, in seconds. The default is 30 seconds. Default + * value: 30 . + * + */ +function PagingGetOdataMultiplePagesOptions() { +} + +/** + * Defines the metadata of PagingGetOdataMultiplePagesOptions + * + * @returns {object} metadata of PagingGetOdataMultiplePagesOptions + * + */ +PagingGetOdataMultiplePagesOptions.prototype.mapper = function () { + return { + required: false, + type: { + name: 'Composite', + className: 'PagingGetOdataMultiplePagesOptions', + modelProperties: { + maxresults: { + required: false, + type: { + name: 'Number' + } + }, + timeout: { + required: false, + defaultValue: 30, + type: { + name: 'Number' + } + } + } + } + }; +}; + +module.exports = PagingGetOdataMultiplePagesOptions; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/index.d.ts b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/index.d.ts index 4257efa352897..1dd3227b11625 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/index.d.ts +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/index.d.ts @@ -60,6 +60,33 @@ export interface Paging { getMultiplePages(options: { clientRequestId? : string, pagingGetMultiplePagesOptions? : models.PagingGetMultiplePagesOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; getMultiplePages(callback: ServiceCallback): void; + /** + * A paging operation that includes a nextLink in odata format that has 10 + * pages + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.clientRequestId] + * + * @param {object} [options.pagingGetOdataMultiplePagesOptions] Additional + * parameters for the operation + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.maxresults] + * Sets the maximum number of items to return in the response. + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.timeout] Sets + * the maximum time that the server can spend processing the request, in + * seconds. The default is 30 seconds. + * + * @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 + */ + getOdataMultiplePages(options: { clientRequestId? : string, pagingGetOdataMultiplePagesOptions? : models.PagingGetOdataMultiplePagesOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getOdataMultiplePages(callback: ServiceCallback): void; + /** * A paging operation that includes a nextLink that has 10 pages * @@ -208,6 +235,36 @@ export interface Paging { getMultiplePagesNext(nextPageLink: string, options: { clientRequestId? : string, pagingGetMultiplePagesOptions? : models.PagingGetMultiplePagesOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; getMultiplePagesNext(nextPageLink: string, callback: ServiceCallback): void; + /** + * A paging operation that includes a nextLink in odata format that has 10 + * pages + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.clientRequestId] + * + * @param {object} [options.pagingGetOdataMultiplePagesOptions] Additional + * parameters for the operation + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.maxresults] + * Sets the maximum number of items to return in the response. + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.timeout] Sets + * the maximum time that the server can spend processing the request, in + * seconds. The default is 30 seconds. + * + * @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 + */ + getOdataMultiplePagesNext(nextPageLink: string, options: { clientRequestId? : string, pagingGetOdataMultiplePagesOptions? : models.PagingGetOdataMultiplePagesOptions, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getOdataMultiplePagesNext(nextPageLink: string, callback: ServiceCallback): void; + /** * A paging operation that includes a nextLink that has 10 pages * diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js index 98f8e2b1efa96..3ac60dd16b076 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js @@ -329,6 +329,180 @@ Paging.prototype.getMultiplePages = function (options, callback) { }); }; +/** + * A paging operation that includes a nextLink in odata format that has 10 + * pages + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.clientRequestId] + * + * @param {object} [options.pagingGetOdataMultiplePagesOptions] Additional + * parameters for the operation + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.maxresults] + * Sets the maximum number of items to return in the response. + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.timeout] Sets + * the maximum time that the server can spend processing the request, in + * seconds. The default is 30 seconds. + * + * @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. + * + * {object} [result] - The deserialized result object. + * See {@link OdataProductResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +Paging.prototype.getOdataMultiplePages = function (options, callback) { + var client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + var clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined; + var pagingGetOdataMultiplePagesOptions = (options && options.pagingGetOdataMultiplePagesOptions !== undefined) ? options.pagingGetOdataMultiplePagesOptions : undefined; + // Validate + try { + if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') { + throw new Error('clientRequestId must be of type string.'); + } + 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 maxresults; + var timeout; + try { + if (pagingGetOdataMultiplePagesOptions !== null && pagingGetOdataMultiplePagesOptions !== undefined) + { + maxresults = pagingGetOdataMultiplePagesOptions.maxresults; + if (maxresults !== null && maxresults !== undefined && typeof maxresults !== 'number') { + throw new Error('maxresults must be of type number.'); + } + } + if (pagingGetOdataMultiplePagesOptions !== null && pagingGetOdataMultiplePagesOptions !== undefined) + { + timeout = pagingGetOdataMultiplePagesOptions.timeout; + if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') { + throw new Error('timeout must be of type number.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = this.client.baseUri + + '//paging/multiple/odata'; + 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 = 'GET'; + httpRequest.headers = {}; + httpRequest.url = requestUrl; + // Set Headers + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (clientRequestId !== undefined && clientRequestId !== null) { + httpRequest.headers['client-request-id'] = clientRequestId; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if (maxresults !== undefined && maxresults !== null) { + httpRequest.headers['maxresults'] = maxresults.toString(); + } + if (timeout !== undefined && timeout !== null) { + httpRequest.headers['timeout'] = timeout.toString(); + } + 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['CloudError']().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; + // Deserialize Response + if (statusCode === 200) { + var parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + var resultMapper = new client.models['OdataProductResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody)); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +}; + /** * A paging operation that includes a nextLink that has 10 pages * @@ -1458,6 +1632,182 @@ Paging.prototype.getMultiplePagesNext = function (nextPageLink, options, callbac }); }; +/** + * A paging operation that includes a nextLink in odata format that has 10 + * pages + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.clientRequestId] + * + * @param {object} [options.pagingGetOdataMultiplePagesOptions] Additional + * parameters for the operation + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.maxresults] + * Sets the maximum number of items to return in the response. + * + * @param {number} [options.pagingGetOdataMultiplePagesOptions.timeout] Sets + * the maximum time that the server can spend processing the request, in + * seconds. The default is 30 seconds. + * + * @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. + * + * {object} [result] - The deserialized result object. + * See {@link OdataProductResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +Paging.prototype.getOdataMultiplePagesNext = function (nextPageLink, options, callback) { + var client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + var clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined; + var pagingGetOdataMultiplePagesOptions = (options && options.pagingGetOdataMultiplePagesOptions !== undefined) ? options.pagingGetOdataMultiplePagesOptions : undefined; + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') { + throw new Error('clientRequestId must be of type string.'); + } + 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 maxresults; + var timeout; + try { + if (pagingGetOdataMultiplePagesOptions !== null && pagingGetOdataMultiplePagesOptions !== undefined) + { + maxresults = pagingGetOdataMultiplePagesOptions.maxresults; + if (maxresults !== null && maxresults !== undefined && typeof maxresults !== 'number') { + throw new Error('maxresults must be of type number.'); + } + } + if (pagingGetOdataMultiplePagesOptions !== null && pagingGetOdataMultiplePagesOptions !== undefined) + { + timeout = pagingGetOdataMultiplePagesOptions.timeout; + if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') { + throw new Error('timeout must be of type number.'); + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + // 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 = 'GET'; + httpRequest.headers = {}; + httpRequest.url = requestUrl; + // Set Headers + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (clientRequestId !== undefined && clientRequestId !== null) { + httpRequest.headers['client-request-id'] = clientRequestId; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if (maxresults !== undefined && maxresults !== null) { + httpRequest.headers['maxresults'] = maxresults.toString(); + } + if (timeout !== undefined && timeout !== null) { + httpRequest.headers['timeout'] = timeout.toString(); + } + 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['CloudError']().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; + // Deserialize Response + if (statusCode === 200) { + var parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + var resultMapper = new client.models['OdataProductResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody)); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +}; + /** * A paging operation that includes a nextLink that has 10 pages * diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/ModelFlattening/models/flattenedProduct.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/ModelFlattening/models/flattenedProduct.js index 3b3012f696108..572e314206b99 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/ModelFlattening/models/flattenedProduct.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/ModelFlattening/models/flattenedProduct.js @@ -96,7 +96,7 @@ FlattenedProduct.prototype.mapper = function () { }, pname: { required: false, - serializedName: 'properties.pname', + serializedName: 'properties.p\\.name', type: { name: 'String' } diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py index 38b4c3391bda8..16d01747b05ae 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py @@ -84,6 +84,12 @@ def test_paging_happy_path(self): with self.assertRaises(GeneratorExit): pages.next() + pages = self.client.paging.get_odata_multiple_pages() + self.assertIsNotNone(pages.next_link) + items = [i for i in pages] + self.assertIsNone(pages.next_link) + self.assertEqual(len(items), 10) + pages = self.client.paging.get_multiple_pages_retry_first() self.assertIsNotNone(pages.next_link) items = [i for i in pages] diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/setup.py index 97aa1ecfa3dd1..16515125fae12 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/setup.py index 4e3dc67a4f96a..c307c1e77ac2c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/setup.py index fee4d2a41a3c6..d8c4a98051266 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/setup.py index 095659cbb3fa4..e06838f4ced9c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/setup.py index cd93aa2dd66d6..0265eef74b905 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py index b60d7cd0eb460..f82dd8c0f784e 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/setup.py index 083369e096dcc..b649cbc67be95 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/setup.py index d66fa596b1ebb..3afd098a07314 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/setup.py index dab3d2e5e77e0..0c397ad78e766 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/__init__.py index 1a166406ca072..c70a5991daebe 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/__init__.py @@ -13,14 +13,18 @@ from .product_properties import ProductProperties from .operation_result import OperationResult from .paging_get_multiple_pages_options import PagingGetMultiplePagesOptions +from .paging_get_odata_multiple_pages_options import PagingGetOdataMultiplePagesOptions from .paging_get_multiple_pages_with_offset_options import PagingGetMultiplePagesWithOffsetOptions from .product_paged import ProductPaged +from .product_paged1 import ProductPaged1 __all__ = [ 'Product', 'ProductProperties', 'OperationResult', 'PagingGetMultiplePagesOptions', + 'PagingGetOdataMultiplePagesOptions', 'PagingGetMultiplePagesWithOffsetOptions', 'ProductPaged', + 'ProductPaged1', ] diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_odata_multiple_pages_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_odata_multiple_pages_options.py new file mode 100644 index 0000000000000..489cc7acdcc79 --- /dev/null +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_odata_multiple_pages_options.py @@ -0,0 +1,30 @@ +# 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 PagingGetOdataMultiplePagesOptions(Model): + """ + Additional parameters for the Paging_getOdataMultiplePages operation. + + :param maxresults: Sets the maximum number of items to return in the + response. + :type maxresults: int + :param timeout: Sets the maximum time that the server can spend + processing the request, in seconds. The default is 30 seconds. Default + value: 30 . + :type timeout: int + """ + + def __init__(self, maxresults=None, timeout=30): + self.maxresults = maxresults + self.timeout = timeout diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_paged1.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_paged1.py new file mode 100644 index 0000000000000..d9c028c20d38a --- /dev/null +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_paged1.py @@ -0,0 +1,27 @@ +# 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.paging import Paged + + +class ProductPaged1(Paged): + """ + A paging container for iterating over a list of Product object + """ + + _attribute_map = { + 'next_link': {'key': 'odata\\.nextLink', 'type': 'str'}, + 'current_page': {'key': 'values', 'type': '[Product]'} + } + + def __init__(self, *args, **kwargs): + + super(ProductPaged1, self).__init__(*args, **kwargs) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py index d43a7e29ced36..cc15cafbc1183 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py @@ -169,6 +169,85 @@ def internal_paging(next_link=None, raw=False): return deserialized + def get_odata_multiple_pages( + self, client_request_id=None, paging_get_odata_multiple_pages_options=None, custom_headers=None, raw=False, **operation_config): + """ + A paging operation that includes a nextLink in odata format that has + 10 pages + + :param client_request_id: + :type client_request_id: str + :param paging_get_odata_multiple_pages_options: Additional parameters + for the operation + :type paging_get_odata_multiple_pages_options: + :class:`PagingGetOdataMultiplePagesOptions + ` + :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: :class:`ProductPaged1 + ` + """ + maxresults = None + if paging_get_odata_multiple_pages_options is not None: + maxresults = paging_get_odata_multiple_pages_options.maxresults + timeout = None + if paging_get_odata_multiple_pages_options is not None: + timeout = paging_get_odata_multiple_pages_options.timeout + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/paging/multiple/odata' + + # Construct parameters + query_parameters = {} + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if client_request_id is not None: + header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + if maxresults is not None: + header_parameters['maxresults'] = self._serialize.header("maxresults", maxresults, 'int') + if timeout is not None: + header_parameters['timeout'] = self._serialize.header("timeout", timeout, 'int') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.ProductPaged1(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.ProductPaged1(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + def get_multiple_pages_with_offset( self, paging_get_multiple_pages_with_offset_options, client_request_id=None, custom_headers=None, raw=False, **operation_config): """ diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/setup.py index 063fc0d9388e6..69e7afeb32977 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/setup.py index b204e8c8c203b..b27c6048bb2f4 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/check_name_availability_result.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/check_name_availability_result.py index dc3874fdaac0e..fffcd807c09b5 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/check_name_availability_result.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/check_name_availability_result.py @@ -24,7 +24,7 @@ class CheckNameAvailabilityResult(Model): used. The Reason element is only returned if NameAvailable is false. Possible values include: 'AccountNameInvalid', 'AlreadyExists' :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/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/foo.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/foo.py index 2de0ad72c8366..5374b4a23f4e3 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/foo.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/foo.py @@ -23,7 +23,7 @@ class Foo(Model): """ _attribute_map = { - 'bar_point': {'key': 'Bar.Point', 'type': 'Bar'}, + 'bar_point': {'key': 'Bar\\.Point', 'type': 'Bar'}, } def __init__(self, bar_point=None): diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account.py index 8ed5eace271c2..e9caad4b2e51f 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account.py @@ -33,12 +33,12 @@ class StorageAccount(Resource): time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded' :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 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. @@ -51,7 +51,7 @@ class StorageAccount(Resource): location of the storage account is available or unavailable. Possible values include: 'Available', 'Unavailable' :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 @@ -67,7 +67,7 @@ class StorageAccount(Resource): Only available if the accountType is StandardGRS or StandardRAGRS. Possible values include: 'Available', 'Unavailable' :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/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_create_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_create_parameters.py index 33c7e0b3d7bc1..129582da4f8f0 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_create_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_create_parameters.py @@ -33,7 +33,7 @@ class StorageAccountCreateParameters(Resource): include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' :type account_type: str or :class:`AccountType - ` + ` """ _validation = { diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_regenerate_key_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_regenerate_key_parameters.py index 7a1da3a0e5757..81bf9601cf309 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_regenerate_key_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_regenerate_key_parameters.py @@ -17,7 +17,7 @@ class StorageAccountRegenerateKeyParameters(Model): :param key_name: Possible values include: 'key1', 'key2' :type key_name: str or :class:`KeyName - ` + ` """ _attribute_map = { diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py index f858c85e39aaf..3c46d035ed47b 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py @@ -35,7 +35,7 @@ class StorageAccountUpdateParameters(Resource): Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' :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/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage.py index 9b3983b234a51..b778e5e433801 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage.py @@ -20,7 +20,7 @@ class Usage(Model): 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' :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/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py index d2583af6ef3d7..4c5b2bdfb0afc 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py @@ -621,7 +621,7 @@ def regenerate_key( :type account_name: str :param key_name: Possible values include: 'key1', 'key2' :type key_name: str or :class:`KeyName - ` + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py index 270e110d8b34f..940ccab4163a8 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs index 464cc1fe44548..91a632f806330 100644 --- a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs +++ b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs @@ -8,6 +8,7 @@ using Microsoft.Rest.Generator.Python.Templates; using Microsoft.Rest.Generator.Python.TemplateModels; using Microsoft.Rest.Generator.Utilities; +using Microsoft.Rest.Generator.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -23,11 +24,13 @@ public class AzurePythonCodeGenerator : PythonCodeGenerator // page extensions class dictionary. private IList pageModels; + private IDictionary> pageClasses; public AzurePythonCodeGenerator(Settings settings) : base(settings) { pageModels = new List(); + pageClasses = new Dictionary>(); Namer = new AzurePythonCodeNamer(); } @@ -84,19 +87,61 @@ private static void NormalizeApiVersion(ServiceClient serviceClient) .ForEach(p => p.DefaultValue = p.DefaultValue.Replace("\"", "'")); } - private string GetPagingSetting(Dictionary extensions, string valueTypeName) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "nextLink")] + private string GetPagingSetting(CompositeType body, Dictionary extensions, string valueTypeName, IDictionary typePageClasses) { var ext = extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer; string nextLinkName = (string)ext["nextLinkName"] ?? "nextLink"; string itemName = (string)ext["itemName"] ?? "value"; - string className = (string)ext["className"]; - if (string.IsNullOrEmpty(className)) + + nextLinkName = nextLinkName.Replace(".", "\\\\."); + itemName = itemName.Replace(".", "\\\\."); + bool findNextLink = false; + bool findItem = false; + foreach (var property in body.ComposedProperties) { - className = valueTypeName + "Paged"; - ext["className"] = className; + if (property.SerializedName == nextLinkName) + { + findNextLink = true; + } + else if (property.SerializedName == itemName) + { + findItem = true; + } } + if (!findNextLink) + { + throw new KeyNotFoundException("Couldn't find the nextLink property specified by extension"); + } + if (!findItem) + { + throw new KeyNotFoundException("Couldn't find the item property specified by extension"); + } + + string className; + var hash = (nextLinkName + "#" + itemName).GetHashCode(); + if (!typePageClasses.ContainsKey(hash)) + { + className = (string)ext["className"]; + if (string.IsNullOrEmpty(className)) + { + if (typePageClasses.Count > 0) + { + className = valueTypeName + String.Format(CultureInfo.InvariantCulture, "Paged{0}", typePageClasses.Count); + } + else + { + className = valueTypeName + "Paged"; + } + } + typePageClasses.Add(hash, className); + } + + className = typePageClasses[hash]; + ext["className"] = className; + var pageModel = new PageTemplateModel(className, nextLinkName, itemName, valueTypeName); if (!pageModels.Contains(pageModel)) { @@ -129,7 +174,12 @@ private void NormalizePaginatedMethods(ServiceClient serviceClient) // if the type is a wrapper over page-able response if (sequenceType != null) { - string pagableTypeName = GetPagingSetting(method.Extensions, sequenceType.ElementType.Name); + string valueType = sequenceType.ElementType.Name; + if (!pageClasses.ContainsKey(valueType)) + { + pageClasses.Add(valueType, new Dictionary()); + } + string pagableTypeName = GetPagingSetting(compositType, method.Extensions, valueType, pageClasses[valueType]); CompositeType pagedResult = new CompositeType { diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flattened_product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flattened_product.py index 55df7eedae364..926f6784f856f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flattened_product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flattened_product.py @@ -53,7 +53,7 @@ class FlattenedProduct(Resource): 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'pname': {'key': 'properties.pname', 'type': 'str'}, + 'pname': {'key': 'properties.p\\.name', 'type': 'str'}, 'flattened_product_type': {'key': 'properties.type', 'type': 'str'}, 'provisioning_state_values': {'key': 'properties.provisioningStateValues', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, diff --git a/AutoRest/Generators/Python/Python/PythonCodeNamer.cs b/AutoRest/Generators/Python/Python/PythonCodeNamer.cs index 53cbd4e2d938f..48b62e4dab002 100644 --- a/AutoRest/Generators/Python/Python/PythonCodeNamer.cs +++ b/AutoRest/Generators/Python/Python/PythonCodeNamer.cs @@ -312,6 +312,10 @@ private IType NormalizeCompositeType(CompositeType compositeType) foreach (var property in compositeType.Properties) { property.Name = GetPropertyName(property.GetClientName()); + if (property.SerializedName != null && !property.WasFlattened()) + { + property.SerializedName = property.SerializedName.Replace(".", "\\\\."); + } property.Type = NormalizeTypeReference(property.Type); } diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb index 2741d89fd50ee..8a53122d34fe7 100644 --- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb +++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb @@ -38,6 +38,20 @@ expect(count).to eq(10) end + it 'should get multiple pages with odata kind nextLink' do + result = @client.paging.get_odata_multiple_pages_async().value! + expect(result.response.status).to eq(200) + expect(result.body.odatanext_link).not_to be_nil + + count = 1 + while result.body.odatanext_link != nil do + result = @client.paging.get_odata_multiple_pages_next_async(result.body.odatanext_link).value! + count += 1 + end + + expect(count).to eq(10) + end + it 'should get multiple pages with offset' do result = @client.paging.get_multiple_pages_with_offset_async(100).value! expect(result.response.status).to eq(200) diff --git a/AutoRest/TestServer/server/routes/model-flatten.js b/AutoRest/TestServer/server/routes/model-flatten.js index e5992ecd24c34..e1d428be7082c 100644 --- a/AutoRest/TestServer/server/routes/model-flatten.js +++ b/AutoRest/TestServer/server/routes/model-flatten.js @@ -16,7 +16,7 @@ var modelFlatten = function (coverage) { properties: { provisioningState: 'Succeeded', provisioningStateValues: 'OK', - pname: 'Product1', + 'p.name': 'Product1', type: 'Flat' }, tags: { tag1: 'value1', tag2: 'value3' }, @@ -43,7 +43,7 @@ var modelFlatten = function (coverage) { properties: { provisioningState: 'Succeeded', provisioningStateValues: 'OK', - pname: 'Product1', + 'p.name': 'Product1', type: 'Flat' }, tags: { tag1: 'value1', tag2: 'value3' }, @@ -71,7 +71,7 @@ var modelFlatten = function (coverage) { properties: { provisioningState: 'Succeeded', provisioningStateValues: 'OK', - pname: 'Product1', + 'p.name': 'Product1', type: 'Flat' }, tags: { tag1: 'value1', tag2: 'value3' }, @@ -95,7 +95,7 @@ var modelFlatten = function (coverage) { properties: { provisioningState: 'Succeeded', provisioningStateValues: 'OK', - pname: 'Product4', + 'p.name': 'Product4', type: 'Flat' }, tags: { tag1: 'value1', tag2: 'value3' }, @@ -125,14 +125,14 @@ var modelFlatten = function (coverage) { var arrayBody = '[{"location":"West US","tags":{"tag1":"value1","tag2":"value3"}},{"location":"Building 44"}]'; - var dictionaryBody = '{"Resource1":{"location":"West US", "tags":{"tag1":"value1", "tag2":"value3"},"properties":{"pname":"Product1","type":"Flat"}},' + - '"Resource2":{"location":"Building 44", "properties":{"pname":"Product2","type":"Flat"}}}'; + var dictionaryBody = '{"Resource1":{"location":"West US", "tags":{"tag1":"value1", "tag2":"value3"},"properties":{"p.name":"Product1","type":"Flat"}},' + + '"Resource2":{"location":"Building 44", "properties":{"p.name":"Product2","type":"Flat"}}}'; var resourceCollectionBody = '{"arrayofresources":[' + - '{"location":"West US", "tags":{"tag1":"value1", "tag2":"value3"}, "properties":{"pname":"Product1","type":"Flat"}},' + - '{"location":"East US", "properties":{"pname":"Product2","type":"Flat"}}],' + + '{"location":"West US", "tags":{"tag1":"value1", "tag2":"value3"}, "properties":{"p.name":"Product1","type":"Flat"}},' + + '{"location":"East US", "properties":{"p.name":"Product2","type":"Flat"}}],' + '"dictionaryofresources":' + dictionaryBody + ',' + - '"productresource":{"location":"India", "properties":{"pname":"Azure","type":"Flat"}}}'; + '"productresource":{"location":"India", "properties":{"p.name":"Azure","type":"Flat"}}}'; var customFlattenBody = { base_product_id: "123", diff --git a/AutoRest/TestServer/server/routes/paging.js b/AutoRest/TestServer/server/routes/paging.js index 953fbf0fc1ff3..e8a9b5157a068 100644 --- a/AutoRest/TestServer/server/routes/paging.js +++ b/AutoRest/TestServer/server/routes/paging.js @@ -31,6 +31,7 @@ var removeScenarioCookie = function(res) { var paging = function(coverage) { coverage['PagingSingle'] = 0; coverage['PagingMultiple'] = 0; + coverage['PagingOdataMultiple'] = 0; coverage['PagingMultiplePath'] = 0; coverage['PagingMultipleRetryFirst'] = 0; coverage['PagingMultipleRetrySecond'] = 0; @@ -57,6 +58,20 @@ var paging = function(coverage) { } }); + router.get('/multiple/odata', function(req, res, next) { + + coverage["PagingOdataMultiple"]++; + res.status(200).end('{ "values" : [ {"properties":{"id": 1, "name": "Product" }}], "odata.nextLink":"' + 'http://localhost:' + utils.getPort() + '/paging/multiple/odata/page/2" }') + }); + + router.get('/multiple/odata/page/:pagenumber', function(req, res, next) { + if (req.params.pagenumber < 10) { + res.status(200).end('{ "values": [ {"properties":{"id" : ' + req.params.pagenumber + ', "name": "product"}} ], "odata.nextLink": "' + 'http://localhost:' + utils.getPort() + '/paging/multiple/odata/page/' + (++req.params.pagenumber) + '"}'); + } else { + res.status(200).end('{"values": [ {"properties":{"id" : ' + req.params.pagenumber + ', "name": "product"}} ]}'); + } + }); + router.get('/multiple/withpath/:offset', function(req, res, next) { coverage["PagingMultiplePath"]++; diff --git a/AutoRest/TestServer/swagger/model-flattening.json b/AutoRest/TestServer/swagger/model-flattening.json index 0ad7424f78cc3..0699f7f8e0914 100644 --- a/AutoRest/TestServer/swagger/model-flattening.json +++ b/AutoRest/TestServer/swagger/model-flattening.json @@ -328,7 +328,7 @@ "properties": { "x-ms-client-flatten": true, "properties": { - "pname": { + "p.name": { "type": "string" }, "type": { diff --git a/AutoRest/TestServer/swagger/paging.json b/AutoRest/TestServer/swagger/paging.json index 6f09812fac7bb..ffa198c3e7c70 100644 --- a/AutoRest/TestServer/swagger/paging.json +++ b/AutoRest/TestServer/swagger/paging.json @@ -83,6 +83,55 @@ } } }, + "/paging/multiple/odata": { + "get": { + "x-ms-pageable": { "nextLinkName": "odata.nextLink", "itemName": "values" }, + "operationId": "Paging_getOdataMultiplePages", + "description": "A paging operation that includes a nextLink in odata format that has 10 pages", + "parameters": [ + { + "name": "client-request-id", + "in": "header", + "required": false, + "type": "string", + }, + { + "name": "maxresults", + "in": "header", + "required": false, + "type": "integer", + "format": "int32", + "description": "Sets the maximum number of items to return in the response.", + "x-ms-parameter-grouping": { + "postfix": "Options" + } + }, + { + "name": "timeout", + "in": "header", + "required": false, + "type": "integer", + "format": "int32", + "default": 30, + "description": "Sets the maximum time that the server can spend processing the request, in seconds. The default is 30 seconds.", + "x-ms-parameter-grouping": { + "postfix": "Options" + } + } + ], + "responses": { + "200": { + "description": "Initial response with ProvisioningState='Canceled'", + "schema": { + "$ref": "#/definitions/OdataProductResult" + } + }, + "default": { + "description": "Unexpected error" + } + } + } + }, "/paging/multiple/withpath/{offset}": { "get": { "x-ms-pageable": { "nextLinkName": "nextLink", "itemName": "values" }, @@ -248,6 +297,19 @@ } } }, + "OdataProductResult": { + "properties": { + "values": { + "type": "array", + "items": { + "$ref": "#/definitions/Product" + } + }, + "odata.nextLink": { + "type": "string" + } + } + }, "Product": { "properties": { "properties": { diff --git a/Samples/azure-storage/Azure.CSharp/StorageManagementClientExtensions.cs b/Samples/azure-storage/Azure.CSharp/StorageManagementClientExtensions.cs deleted file mode 100644 index 07c002f3e98e1..0000000000000 --- a/Samples/azure-storage/Azure.CSharp/StorageManagementClientExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ - -namespace Petstore -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - - /// - /// Extension methods for StorageManagementClient. - /// - public static partial class StorageManagementClientExtensions - { - } -} diff --git a/Samples/azure-storage/Azure.Java/models/Resource.java b/Samples/azure-storage/Azure.Java/models/Resource.java deleted file mode 100644 index 9def60a007f40..0000000000000 --- a/Samples/azure-storage/Azure.Java/models/Resource.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - */ - -package petstore.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Map; -import com.microsoft.azure.BaseResource; - -/** - * The Resource model. - */ -public class Resource extends BaseResource { - /** - * Resource Id. - */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String id; - - /** - * Resource name. - */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String name; - - /** - * Resource type. - */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String type; - - /** - * Resource location. - */ - private String location; - - /** - * Resource tags. - */ - private Map tags; - - /** - * Get the id value. - * - * @return the id value - */ - public String getId() { - return this.id; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String getName() { - return this.name; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String getType() { - return this.type; - } - - /** - * Get the location value. - * - * @return the location value - */ - public String getLocation() { - return this.location; - } - - /** - * Set the location value. - * - * @param location the location value to set - */ - public void setLocation(String location) { - this.location = location; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - */ - public void setTags(Map tags) { - this.tags = tags; - } - -} diff --git a/Samples/azure-storage/Azure.NodeJS/models/storageAccountListResult.js b/Samples/azure-storage/Azure.NodeJS/models/storageAccountListResult.js index fa9ccc62adaa0..c2aa1bfe1c631 100644 --- a/Samples/azure-storage/Azure.NodeJS/models/storageAccountListResult.js +++ b/Samples/azure-storage/Azure.NodeJS/models/storageAccountListResult.js @@ -13,6 +13,8 @@ var util = require('util'); * @member {array} [value] Gets the list of storage accounts and their * properties. * + * @member {string} [nextLink] + * */ function StorageAccountListResult() { } diff --git a/Samples/azure-storage/Azure.NodeJS/models/usageListResult.js b/Samples/azure-storage/Azure.NodeJS/models/usageListResult.js index 2a343cb606976..da304e333fc0d 100644 --- a/Samples/azure-storage/Azure.NodeJS/models/usageListResult.js +++ b/Samples/azure-storage/Azure.NodeJS/models/usageListResult.js @@ -12,6 +12,8 @@ var util = require('util'); * The List Usages operation response. * @member {array} [value] Gets or sets the list Storage Resource Usages. * + * @member {string} [nextLink] + * */ function UsageListResult() { } diff --git a/Samples/azure-storage/Azure.Python/setup.py b/Samples/azure-storage/Azure.Python/setup.py index 3260175533423..f52ae66bd608d 100644 --- a/Samples/azure-storage/Azure.Python/setup.py +++ b/Samples/azure-storage/Azure.Python/setup.py @@ -15,7 +15,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.3.0", "msrestazure>=0.3.0"] +REQUIRES = ["msrest>=0.4.0", "msrestazure>=0.4.0"] setup( name=NAME, 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 3534f13656809..4d411d1aca9aa 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,8 +16,7 @@ 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 or :class:`Reason - ` + :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 0e5ad1120ce92..d4abd7edb5c4d 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 @@ -12,12 +12,12 @@ class StorageAccountProperties(Model): time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded' :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 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. @@ -29,7 +29,7 @@ class StorageAccountProperties(Model): location of the storage account is available or unavailable. Possible values include: 'Available', 'Unavailable' :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 @@ -45,7 +45,7 @@ class StorageAccountProperties(Model): Only available if the accountType is StandardGRS or StandardRAGRS. Possible values include: 'Available', 'Unavailable' :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 b228be46caa06..98a9a5e216827 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 @@ -12,7 +12,7 @@ class StorageAccountPropertiesCreateParameters(Model): include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' :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 93634e3813e4e..1f180b027c4dc 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 @@ -14,7 +14,7 @@ class StorageAccountPropertiesUpdateParameters(Model): Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' :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 14ad7ea189b99..ea38dc3535dae 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py @@ -12,8 +12,7 @@ class Usage(Model): :param unit: Gets the unit of measurement. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - :type unit: str or :class:`UsageUnit - ` + :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.Ruby/azure_storage/models/storage_account_list_result.rb b/Samples/azure-storage/Azure.Ruby/azure_storage/models/storage_account_list_result.rb index e64e625a61588..1b711341335b8 100644 --- a/Samples/azure-storage/Azure.Ruby/azure_storage/models/storage_account_list_result.rb +++ b/Samples/azure-storage/Azure.Ruby/azure_storage/models/storage_account_list_result.rb @@ -13,6 +13,9 @@ class StorageAccountListResult # their properties. attr_accessor :value + # @return [String] + attr_accessor :next_link + # # Validate the object. Throws ValidationError if validation fails. # @@ -42,6 +45,9 @@ def self.serialize_object(object) end output_object['value'] = serialized_property unless serialized_property.nil? + serialized_property = object.next_link + output_object['nextLink'] = serialized_property unless serialized_property.nil? + output_object end @@ -67,6 +73,9 @@ def self.deserialize_object(object) end output_object.value = deserialized_property + deserialized_property = object['nextLink'] + output_object.next_link = deserialized_property + output_object end end diff --git a/Samples/azure-storage/Azure.Ruby/azure_storage/models/usage_list_result.rb b/Samples/azure-storage/Azure.Ruby/azure_storage/models/usage_list_result.rb index 61b109b5e391a..be59e10042364 100644 --- a/Samples/azure-storage/Azure.Ruby/azure_storage/models/usage_list_result.rb +++ b/Samples/azure-storage/Azure.Ruby/azure_storage/models/usage_list_result.rb @@ -12,6 +12,9 @@ class UsageListResult # @return [Array] Gets or sets the list Storage Resource Usages. attr_accessor :value + # @return [String] + attr_accessor :next_link + # # Validate the object. Throws ValidationError if validation fails. # @@ -41,6 +44,9 @@ def self.serialize_object(object) end output_object['value'] = serialized_property unless serialized_property.nil? + serialized_property = object.next_link + output_object['nextLink'] = serialized_property unless serialized_property.nil? + output_object end @@ -66,6 +72,9 @@ def self.deserialize_object(object) end output_object.value = deserialized_property + deserialized_property = object['nextLink'] + output_object.next_link = deserialized_property + output_object end end diff --git a/Samples/azure-storage/azure-storage.json b/Samples/azure-storage/azure-storage.json index f19af9c23bac1..2d2bb37a2589b 100644 --- a/Samples/azure-storage/azure-storage.json +++ b/Samples/azure-storage/azure-storage.json @@ -657,6 +657,9 @@ "$ref": "#/definitions/StorageAccount" }, "description": "Gets the list of storage accounts and their properties." + }, + "nextLink": { + "type": "string" } }, "description": "The list storage accounts operation response." @@ -772,6 +775,9 @@ "$ref": "#/definitions/Usage" }, "description": "Gets or sets the list Storage Resource Usages." + }, + "nextLink": { + "type": "string" } }, "description": "The List Usages operation response."