diff --git a/.travis.yml b/.travis.yml index 700c37840023e..51223465035c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,8 @@ install: # Install android SDK - mkdir android - wget -qO- "http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz" | tar -zxv -C ./android - - echo y | ./android/android-sdk-linux/tools/android update sdk --all --filter platform-tools,android-23,build-tools-23.0.1,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --force + - echo y | ./android/android-sdk-linux/tools/android update sdk --all --filter platform-tools,android-23,build-tools-23.0.1 --no-ui --force + - echo y | ./android/android-sdk-linux/tools/android update sdk --all --filter extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --force - export ANDROID_HOME=`pwd`/android/android-sdk-linux script: - dnvm install 1.0.0-rc1-final -r mono diff --git a/AutoRest.sln b/AutoRest.sln index f616c9ac420d0..b11b89d798ca5 100644 --- a/AutoRest.sln +++ b/AutoRest.sln @@ -118,6 +118,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRest.Modeler.CompositeS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRest.Modeler.CompositeSwagger.Tests", "AutoRest\Modelers\CompositeSwagger.Tests\AutoRest.Modeler.CompositeSwagger.Tests.csproj", "{DA37E6A9-5D59-45A3-A809-ABA85031C369}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AzureResourceSchema", "AzureResourceSchema", "{B6A1FC1E-0779-4900-84EE-262DD0E53FF4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRest.Generator.AzureResourceSchema", "AutoRest\Generators\AzureResourceSchema\AzureResourceSchema\AutoRest.Generator.AzureResourceSchema.csproj", "{654344A5-0556-49C7-BFB3-59676D7440D3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRest.Generator.AzureResourceSchema.Tests", "AutoRest\Generators\AzureResourceSchema\AzureResourceSchema.Tests\AutoRest.Generator.AzureResourceSchema.Tests.csproj", "{1C3B4A33-E045-4C8F-9202-1B651A686567}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Net45-Debug|Any CPU = Net45-Debug|Any CPU @@ -366,6 +372,22 @@ Global {DA37E6A9-5D59-45A3-A809-ABA85031C369}.Portable-Debug|Any CPU.Build.0 = Portable-Debug|Any CPU {DA37E6A9-5D59-45A3-A809-ABA85031C369}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU {DA37E6A9-5D59-45A3-A809-ABA85031C369}.Portable-Release|Any CPU.Build.0 = Portable-Release|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Net45-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Net45-Debug|Any CPU.Build.0 = Debug|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Net45-Release|Any CPU.ActiveCfg = Release|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Net45-Release|Any CPU.Build.0 = Release|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Portable-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Portable-Debug|Any CPU.Build.0 = Debug|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Portable-Release|Any CPU.ActiveCfg = Release|Any CPU + {654344A5-0556-49C7-BFB3-59676D7440D3}.Portable-Release|Any CPU.Build.0 = Release|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Net45-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Net45-Debug|Any CPU.Build.0 = Debug|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Net45-Release|Any CPU.ActiveCfg = Release|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Net45-Release|Any CPU.Build.0 = Release|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Portable-Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Portable-Debug|Any CPU.Build.0 = Debug|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Portable-Release|Any CPU.ActiveCfg = Release|Any CPU + {1C3B4A33-E045-4C8F-9202-1B651A686567}.Portable-Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -407,5 +429,8 @@ Global {74BE0601-FF65-4B46-8A8B-E670056061C4} = {74F7C659-952F-400C-839F-90BED9BB66C3} {31AEC9B5-35C9-4FEA-8420-4C34D3FEAAC8} = {02144BF6-4489-4AFC-9B2D-0306C3DD3C19} {DA37E6A9-5D59-45A3-A809-ABA85031C369} = {02144BF6-4489-4AFC-9B2D-0306C3DD3C19} + {B6A1FC1E-0779-4900-84EE-262DD0E53FF4} = {EF9E346D-70C6-45F5-8FF9-9B734F4A1298} + {654344A5-0556-49C7-BFB3-59676D7440D3} = {B6A1FC1E-0779-4900-84EE-262DD0E53FF4} + {1C3B4A33-E045-4C8F-9202-1B651A686567} = {B6A1FC1E-0779-4900-84EE-262DD0E53FF4} EndGlobalSection EndGlobal diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj new file mode 100644 index 0000000000000..01522ea89f2b4 --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AutoRest.Generator.AzureResourceSchema.Tests.csproj @@ -0,0 +1,89 @@ + + + + + + Debug + AnyCPU + {1C3B4A33-E045-4C8F-9202-1B651A686567} + Library + Properties + AutoRest.Generator.AzureResourceSchema.Tests + AutoRest.Generator.AzureResourceSchema.Tests + v4.5.2 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + True + + + ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + True + + + ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + True + + + + + + + + PreserveNewest + + + + + {654344a5-0556-49c7-bfb3-59676d7440d3} + AutoRest.Generator.AzureResourceSchema + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Properties/AssemblyInfo.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..d8be4efbcaee3 --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AutoRest.Generator.AzureResourceSchema.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutoRest.Generator.AzureResourceSchema.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1c3b4a33-e045-4c8f-9202-1b651a686567")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/packages.config b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/packages.config new file mode 100644 index 0000000000000..4e690e09d9def --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj new file mode 100644 index 0000000000000..9afbe46b7ef40 --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {654344A5-0556-49C7-BFB3-59676D7440D3} + Library + Properties + Microsoft.Rest.Generator.AzureResourceSchema + AutoRest.Generator.AzureResourceSchema + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..34f7036d5899a --- /dev/null +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AutoRest.Generator.AzureResourceSchema")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutoRest.Generator.AzureResourceSchema")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("654344a5-0556-49c7-bfb3-59676d7440d3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs index 0c6e31b1c1467..0d5c31f0e5182 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs @@ -50,6 +50,7 @@ using Fixtures.PetstoreV2; using Fixtures.AcceptanceTestsCompositeBoolIntClient; using Fixtures.AcceptanceTestsCustomBaseUri; +using Fixtures.AcceptanceTestsCustomBaseUriMoreOptions; using System.Net.Http; using Fixtures.AcceptanceTestsModelFlattening; using Fixtures.AcceptanceTestsModelFlattening.Models; @@ -1951,6 +1952,21 @@ public void CustomBaseUriTests() } } + [Fact] + public void CustomBaseUriMoreOptionsTests() + { + SwaggerSpecRunner.RunTests( + SwaggerPath("custom-baseUrl-more-options.json"), ExpectedPath("CustomBaseUriMoreOptions")); + using (var client = new AutoRestParameterizedCustomHostTestClient()) + { + client.SubscriptionId = "test12"; + // small modification to the "host" portion to include the port and the '.' + client.DnsSuffix = string.Format(CultureInfo.InvariantCulture, "{0}.:{1}", "host", Fixture.Port); + Assert.Equal(HttpStatusCode.OK, + client.Paths.GetEmptyWithHttpMessagesAsync("http://lo", "cal", "key1").Result.Response.StatusCode); + } + } + [Fact] public void CustomBaseUriNegativeTests() { diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs new file mode 100644 index 0000000000000..e680cbe6a8731 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs @@ -0,0 +1,128 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Diagnostics; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial class AutoRestParameterizedCustomHostTestClient : ServiceClient, IAutoRestParameterizedCustomHostTestClient + { + /// + /// The base URI of the service. + /// + internal string BaseUri {get; set;} + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// The subscription id with value 'test12'. + /// + public string SubscriptionId { get; set; } + + /// + /// A string value that is used as a global part of the parameterized host. + /// Default value 'host'. + /// + public string DnsSuffix { get; set; } + + /// + /// Gets the IPaths. + /// + public virtual IPaths Paths { get; private set; } + + /// + /// Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestParameterizedCustomHostTestClient(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public AutoRestParameterizedCustomHostTestClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.Paths = new Paths(this); + this.BaseUri = "{vault}{secret}{dnsSuffix}"; + this.DnsSuffix = "host"; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + } + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs new file mode 100644 index 0000000000000..87db999d81c42 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.AcceptanceTestsCustomBaseUriMoreOptions +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial interface IAutoRestParameterizedCustomHostTestClient : IDisposable + { + /// + /// The base URI of the service. + /// + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// The subscription id with value 'test12'. + /// + string SubscriptionId { get; set; } + + /// + /// A string value that is used as a global part of the parameterized + /// host. Default value 'host'. + /// + string DnsSuffix { get; set; } + + + /// + /// Gets the IPaths. + /// + IPaths Paths { get; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IPaths.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IPaths.cs new file mode 100644 index 0000000000000..a117b914e7526 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IPaths.cs @@ -0,0 +1,47 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Models; + + /// + /// Paths operations. + /// + public partial interface IPaths + { + /// + /// Get a 200 to test a valid base uri + /// + /// + /// The vault name, e.g. https://myvault + /// + /// + /// Secret value. + /// + /// + /// The key name with value 'key1'. + /// + /// + /// The key version. Default value 'v1'. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task GetEmptyWithHttpMessagesAsync(string vault, string secret, string keyName, string keyVersion = "v1", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/Error.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/Error.cs new file mode 100644 index 0000000000000..82a4873e61389 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/Error.cs @@ -0,0 +1,45 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() { } + + /// + /// Initializes a new instance of the Error class. + /// + public Error(int? status = default(int?), string message = default(string)) + { + Status = status; + Message = message; + } + + /// + /// + [JsonProperty(PropertyName = "status")] + public int? Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/ErrorException.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/ErrorException.cs new file mode 100644 index 0000000000000..e3ab1c0a08abc --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Models/ErrorException.cs @@ -0,0 +1,99 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions.Models +{ + using Microsoft.Rest; + using System; + using System.Net.Http; + using System.Runtime.Serialization; +#if !PORTABLE && !DNXCORE50 + using System.Security.Permissions; +#endif + + /// + /// Exception thrown for an invalid response with Error information. + /// +#if !PORTABLE && !DNXCORE50 + [Serializable] +#endif + public class ErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public Error Body { get; set; } + + /// + /// Initializes a new instance of the ErrorException class. + /// + public ErrorException() + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + public ErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + /// Inner exception. + public ErrorException(string message, Exception innerException) + : base(message, innerException) + { + } + +#if !PORTABLE && !DNXCORE50 + /// + /// Initializes a new instance of the ErrorException class. + /// + /// Serialization info. + /// Streaming context. + protected ErrorException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + /// + /// Serializes content of the exception. + /// + /// Serialization info. + /// Streaming context. + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + if (info == null) + { + throw new ArgumentNullException("info"); + } + + info.AddValue("Request", Request); + info.AddValue("Response", Response); + info.AddValue("Body", Body); + } +#endif + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs new file mode 100644 index 0000000000000..a8599cf083382 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs @@ -0,0 +1,203 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Text; + using System.Text.RegularExpressions; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using Models; + + /// + /// Paths operations. + /// + public partial class Paths : IServiceOperations, IPaths + { + /// + /// Initializes a new instance of the Paths class. + /// + /// + /// Reference to the service client. + /// + public Paths(AutoRestParameterizedCustomHostTestClient client) + { + if (client == null) + { + throw new ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the AutoRestParameterizedCustomHostTestClient + /// + public AutoRestParameterizedCustomHostTestClient Client { get; private set; } + + /// + /// Get a 200 to test a valid base uri + /// + /// + /// The vault name, e.g. https://myvault + /// + /// + /// Secret value. + /// + /// + /// The key name with value 'key1'. + /// + /// + /// The key version. Default value 'v1'. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task GetEmptyWithHttpMessagesAsync(string vault, string secret, string keyName, string keyVersion = "v1", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (vault == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vault"); + } + if (secret == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secret"); + } + if (this.Client.DnsSuffix == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.DnsSuffix"); + } + if (keyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); + } + if (this.Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("vault", vault); + tracingParameters.Add("secret", secret); + tracingParameters.Add("keyName", keyName); + tracingParameters.Add("keyVersion", keyVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetEmpty", tracingParameters); + } + // Construct URL + var _baseUrl = this.Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "customuri/{subscriptionId}/{keyName}"; + _url = _url.Replace("{vault}", vault); + _url = _url.Replace("{secret}", secret); + _url = _url.Replace("{dnsSuffix}", this.Client.DnsSuffix); + _url = _url.Replace("{keyName}", Uri.EscapeDataString(keyName)); + _url = _url.Replace("{subscriptionId}", Uri.EscapeDataString(this.Client.SubscriptionId)); + List _queryParameters = new List(); + if (keyVersion != null) + { + _queryParameters.Add(string.Format("keyVersion={0}", Uri.EscapeDataString(keyVersion))); + } + 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 (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; + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/PathsExtensions.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/PathsExtensions.cs new file mode 100644 index 0000000000000..c553414304ed0 --- /dev/null +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/PathsExtensions.cs @@ -0,0 +1,74 @@ +// 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.AcceptanceTestsCustomBaseUriMoreOptions +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Models; + + /// + /// Extension methods for Paths. + /// + public static partial class PathsExtensions + { + /// + /// Get a 200 to test a valid base uri + /// + /// + /// The operations group for this extension method. + /// + /// + /// The vault name, e.g. https://myvault + /// + /// + /// Secret value. + /// + /// + /// The key name with value 'key1'. + /// + /// + /// The key version. Default value 'v1'. + /// + public static void GetEmpty(this IPaths operations, string vault, string secret, string keyName, string keyVersion = "v1") + { + Task.Factory.StartNew(s => ((IPaths)s).GetEmptyAsync(vault, secret, keyName, keyVersion), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a 200 to test a valid base uri + /// + /// + /// The operations group for this extension method. + /// + /// + /// The vault name, e.g. https://myvault + /// + /// + /// Secret value. + /// + /// + /// The key name with value 'key1'. + /// + /// + /// The key version. Default value 'v1'. + /// + /// + /// The cancellation token. + /// + public static async Task GetEmptyAsync(this IPaths operations, string vault, string secret, string keyName, string keyVersion = "v1", CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.GetEmptyWithHttpMessagesAsync(vault, secret, keyName, keyVersion, null, cancellationToken).ConfigureAwait(false); + } + + } +} diff --git a/AutoRest/Generators/Extensions/Extensions/Extensions.cs b/AutoRest/Generators/Extensions/Extensions/Extensions.cs index e974d9563af25..620a2d594c83e 100644 --- a/AutoRest/Generators/Extensions/Extensions/Extensions.cs +++ b/AutoRest/Generators/Extensions/Extensions/Extensions.cs @@ -12,6 +12,8 @@ using Microsoft.Rest.Modeler.Swagger.Model; using Newtonsoft.Json.Linq; using Newtonsoft.Json; +using System.Text.RegularExpressions; +using Microsoft.Rest.Generator.Properties; namespace Microsoft.Rest.Generator { @@ -27,6 +29,8 @@ public abstract class Extensions public const string FlattenOriginalTypeName = "x-ms-client-flatten-original-type-name"; public const string ParameterGroupExtension = "x-ms-parameter-grouping"; public const string ParameterizedHostExtension = "x-ms-parameterized-host"; + public const string UseSchemePrefix = "useSchemePrefix"; + public const string PositionInOperation = "positionInOperation"; private static bool hostChecked = false; @@ -67,6 +71,28 @@ public static void ProcessParameterizedHost(ServiceClient serviceClient, Setting { var hostTemplate = (string)hostExtension["hostTemplate"]; var parametersJson = hostExtension["parameters"].ToString(); + var useSchemePrefix = true; + if (hostExtension[UseSchemePrefix] != null) + { + useSchemePrefix = bool.Parse(hostExtension[UseSchemePrefix].ToString()); + } + + var position = "first"; + + if (hostExtension[PositionInOperation] != null) + { + var pat = "^(fir|la)st$"; + Regex r = new Regex(pat, RegexOptions.IgnoreCase); + var text = hostExtension[PositionInOperation].ToString(); + Match m = r.Match(text); + if (!m.Success) + { + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, + Resources.InvalidExtensionProperty, text, PositionInOperation, ParameterizedHostExtension, "first, last")); + } + position = text; + } + if (!string.IsNullOrEmpty(parametersJson)) { var jsonSettings = new JsonSerializerSettings @@ -76,7 +102,7 @@ public static void ProcessParameterizedHost(ServiceClient serviceClient, Setting }; var swaggerParams = JsonConvert.DeserializeObject>(parametersJson, jsonSettings); - + List hostParamList = new List(); foreach (var swaggerParameter in swaggerParams) { // Build parameter @@ -89,16 +115,33 @@ public static void ProcessParameterizedHost(ServiceClient serviceClient, Setting parameter.ClientProperty = serviceClient.Properties.Single(p => p.SerializedName.Equals(parameter.SerializedName)); } parameter.Extensions["hostParameter"] = true; + hostParamList.Add(parameter); + } - foreach (var method in serviceClient.Methods) + foreach (var method in serviceClient.Methods) + { + if (position.Equals("first", StringComparison.OrdinalIgnoreCase)) { - method.Parameters.Add(parameter); + method.Parameters.InsertRange(0, hostParamList); } + else + { + method.Parameters.AddRange(hostParamList); + } + } - - serviceClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", - modeler.ServiceDefinition.Schemes[0].ToString().ToLowerInvariant(), - hostTemplate, modeler.ServiceDefinition.BasePath); + if (useSchemePrefix) + { + serviceClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", + modeler.ServiceDefinition.Schemes[0].ToString().ToLowerInvariant(), + hostTemplate, modeler.ServiceDefinition.BasePath); + } + else + { + serviceClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}", + hostTemplate, modeler.ServiceDefinition.BasePath); + } + } } } diff --git a/AutoRest/Generators/Extensions/Extensions/Properties/Resources.Designer.cs b/AutoRest/Generators/Extensions/Extensions/Properties/Resources.Designer.cs index 689a601b826f3..f98e2ea0b022c 100644 --- a/AutoRest/Generators/Extensions/Extensions/Properties/Resources.Designer.cs +++ b/AutoRest/Generators/Extensions/Extensions/Properties/Resources.Designer.cs @@ -69,6 +69,15 @@ internal static string HeadMethodInvalidResponses { } } + /// + /// Looks up a localized string similar to The value '{0}' provided for property '{1}' of extension '{2} is invalid. Valid values are: '{3}'.. + /// + internal static string InvalidExtensionProperty { + get { + return ResourceManager.GetString("InvalidExtensionProperty", resourceCulture); + } + } + /// /// Looks up a localized string similar to Azure resource {0} is missing required 'properties' property.. /// diff --git a/AutoRest/Generators/Extensions/Extensions/Properties/Resources.resx b/AutoRest/Generators/Extensions/Extensions/Properties/Resources.resx index d06a580a716fe..7df584f0a47aa 100644 --- a/AutoRest/Generators/Extensions/Extensions/Properties/Resources.resx +++ b/AutoRest/Generators/Extensions/Extensions/Properties/Resources.resx @@ -120,6 +120,9 @@ Head method '{0}' should contain only 200 level responses, or 404. + + The value '{0}' provided for property '{1}' of extension '{2} is invalid. Valid values are: '{3}'. + Azure resource {0} is missing required 'properties' property. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClient.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClient.java new file mode 100644 index 0000000000000..7c5bb29be05d4 --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClient.java @@ -0,0 +1,86 @@ +/** + * 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.custombaseurimoreoptions; + +import java.util.List; +import okhttp3.Interceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; +import com.microsoft.rest.serializer.JacksonMapperAdapter; + +/** + * The interface for AutoRestParameterizedCustomHostTestClient class. + */ +public interface AutoRestParameterizedCustomHostTestClient { + /** + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. + */ + AutoRestBaseUrl getBaseUrl(); + + /** + * Gets the list of interceptors the OkHttp client will execute. + * + * @return the list of interceptors. + */ + List getClientInterceptors(); + + /** + * Sets the logging level for OkHttp client. + * + * @param logLevel the logging level enum. + */ + void setLogLevel(Level logLevel); + + /** + * Gets the adapter for {@link com.fasterxml.jackson.databind.ObjectMapper} for serialization + * and deserialization operations.. + * + * @return the adapter. + */ + JacksonMapperAdapter getMapperAdapter(); + + /** + * Gets The subscription id with value 'test12'.. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Sets The subscription id with value 'test12'.. + * + * @param subscriptionId the subscriptionId value. + */ + void setSubscriptionId(String subscriptionId); + + /** + * Gets A string value that is used as a global part of the parameterized host. Default value 'host'.. + * + * @return the dnsSuffix value. + */ + String getDnsSuffix(); + + /** + * Sets A string value that is used as a global part of the parameterized host. Default value 'host'.. + * + * @param dnsSuffix the dnsSuffix value. + */ + void setDnsSuffix(String dnsSuffix); + + /** + * Gets the PathsOperations object to access its operations. + * @return the PathsOperations object. + */ + PathsOperations getPathsOperations(); + +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClientImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClientImpl.java new file mode 100644 index 0000000000000..ad9fe946dc423 --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/AutoRestParameterizedCustomHostTestClientImpl.java @@ -0,0 +1,121 @@ +/** + * 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.custombaseurimoreoptions; + +import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; +import okhttp3.OkHttpClient; +import retrofit2.Retrofit; + +/** + * Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class. + */ +public final class AutoRestParameterizedCustomHostTestClientImpl extends ServiceClient implements AutoRestParameterizedCustomHostTestClient { + /** + * The URL used as the base for all cloud service requests. + */ + private final AutoRestBaseUrl baseUrl; + + /** + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. + */ + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; + } + + /** The subscription id with value 'test12'. */ + private String subscriptionId; + + /** + * Gets The subscription id with value 'test12'. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * Sets The subscription id with value 'test12'. + * + * @param subscriptionId the subscriptionId value. + */ + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + /** A string value that is used as a global part of the parameterized host. Default value 'host'. */ + private String dnsSuffix; + + /** + * Gets A string value that is used as a global part of the parameterized host. Default value 'host'. + * + * @return the dnsSuffix value. + */ + public String getDnsSuffix() { + return this.dnsSuffix; + } + + /** + * Sets A string value that is used as a global part of the parameterized host. Default value 'host'. + * + * @param dnsSuffix the dnsSuffix value. + */ + public void setDnsSuffix(String dnsSuffix) { + this.dnsSuffix = dnsSuffix; + } + + /** + * Gets the PathsOperations object to access its operations. + * @return the PathsOperations object. + */ + public PathsOperations getPathsOperations() { + return new PathsOperationsImpl(this.retrofitBuilder.client(clientBuilder.build()).build(), this); + } + + /** + * Initializes an instance of AutoRestParameterizedCustomHostTestClient client. + */ + public AutoRestParameterizedCustomHostTestClientImpl() { + this("{vault}{secret}{dnsSuffix}"); + } + + /** + * Initializes an instance of AutoRestParameterizedCustomHostTestClient client. + * + * @param baseUrl the base URL of the host + */ + private AutoRestParameterizedCustomHostTestClientImpl(String baseUrl) { + super(); + this.baseUrl = new AutoRestBaseUrl(baseUrl); + initialize(); + } + + /** + * Initializes an instance of AutoRestParameterizedCustomHostTestClient client. + * + * @param clientBuilder the builder for building up an {@link OkHttpClient} + * @param retrofitBuilder the builder for building up a {@link Retrofit} + */ + public AutoRestParameterizedCustomHostTestClientImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + super(clientBuilder, retrofitBuilder); + this.baseUrl = new AutoRestBaseUrl("{vault}{secret}{dnsSuffix}"); + initialize(); + } + + @Override + protected void initialize() { + super.initialize(); + this.retrofitBuilder.baseUrl(baseUrl); + } +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperations.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperations.java new file mode 100644 index 0000000000000..6273f3426d73c --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperations.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.custombaseurimoreoptions; + +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import fixtures.custombaseurimoreoptions.models.ErrorException; +import java.io.IOException; + +/** + * An instance of this class provides access to all the operations defined + * in PathsOperations. + */ +public interface PathsOperations { + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + ServiceResponse getEmpty(String vault, String secret, String keyName) throws ErrorException, IOException, IllegalArgumentException; + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall getEmptyAsync(String vault, String secret, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException; + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @param keyVersion The key version. Default value 'v1'. + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + ServiceResponse getEmpty(String vault, String secret, String keyName, String keyVersion) throws ErrorException, IOException, IllegalArgumentException; + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @param keyVersion The key version. Default value 'v1'. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall getEmptyAsync(String vault, String secret, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException; + +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperationsImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperationsImpl.java new file mode 100644 index 0000000000000..13994720257bd --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/PathsOperationsImpl.java @@ -0,0 +1,245 @@ +/** + * 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.custombaseurimoreoptions; + +import com.google.common.reflect.TypeToken; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseBuilder; +import com.microsoft.rest.ServiceResponseCallback; +import fixtures.custombaseurimoreoptions.models.ErrorException; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import retrofit2.Retrofit; + +/** + * An instance of this class provides access to all the operations defined + * in PathsOperations. + */ +public final class PathsOperationsImpl implements PathsOperations { + /** The Retrofit service to perform REST calls. */ + private PathsService service; + /** The service client containing this operation class. */ + private AutoRestParameterizedCustomHostTestClient client; + + /** + * Initializes an instance of PathsOperations. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PathsOperationsImpl(Retrofit retrofit, AutoRestParameterizedCustomHostTestClient client) { + this.service = retrofit.create(PathsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PathsOperations to be + * used by Retrofit to perform actually REST calls. + */ + interface PathsService { + @Headers("Content-Type: application/json; charset=utf-8") + @GET("customuri/{subscriptionId}/{keyName}") + Call getEmpty(@Path("keyName") String keyName, @Path("subscriptionId") String subscriptionId, @Query("keyVersion") String keyVersion); + + } + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse getEmpty(String vault, String secret, String keyName) throws ErrorException, IOException, IllegalArgumentException { + if (vault == null) { + throw new IllegalArgumentException("Parameter vault is required and cannot be null."); + } + if (secret == null) { + throw new IllegalArgumentException("Parameter secret is required and cannot be null."); + } + if (this.client.getDnsSuffix() == null) { + throw new IllegalArgumentException("Parameter this.client.getDnsSuffix() is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.client.getSubscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.getSubscriptionId() is required and cannot be null."); + } + final String keyVersion = null; + this.client.getBaseUrl().set("{vault}", vault); + this.client.getBaseUrl().set("{secret}", secret); + this.client.getBaseUrl().set("{dnsSuffix}", this.client.getDnsSuffix()); + Call call = service.getEmpty(keyName, this.client.getSubscriptionId(), keyVersion); + return getEmptyDelegate(call.execute()); + } + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @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 getEmptyAsync(String vault, String secret, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vault == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vault is required and cannot be null.")); + return null; + } + if (secret == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secret is required and cannot be null.")); + return null; + } + if (this.client.getDnsSuffix() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getDnsSuffix() is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.client.getSubscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getSubscriptionId() is required and cannot be null.")); + return null; + } + final String keyVersion = null; + this.client.getBaseUrl().set("{vault}", vault); + this.client.getBaseUrl().set("{secret}", secret); + this.client.getBaseUrl().set("{dnsSuffix}", this.client.getDnsSuffix()); + Call call = service.getEmpty(keyName, this.client.getSubscriptionId(), keyVersion); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getEmptyDelegate(response)); + } catch (ErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @param keyVersion The key version. Default value 'v1'. + * @throws ErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the {@link ServiceResponse} object if successful. + */ + public ServiceResponse getEmpty(String vault, String secret, String keyName, String keyVersion) throws ErrorException, IOException, IllegalArgumentException { + if (vault == null) { + throw new IllegalArgumentException("Parameter vault is required and cannot be null."); + } + if (secret == null) { + throw new IllegalArgumentException("Parameter secret is required and cannot be null."); + } + if (this.client.getDnsSuffix() == null) { + throw new IllegalArgumentException("Parameter this.client.getDnsSuffix() is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.client.getSubscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.getSubscriptionId() is required and cannot be null."); + } + this.client.getBaseUrl().set("{vault}", vault); + this.client.getBaseUrl().set("{secret}", secret); + this.client.getBaseUrl().set("{dnsSuffix}", this.client.getDnsSuffix()); + Call call = service.getEmpty(keyName, this.client.getSubscriptionId(), keyVersion); + return getEmptyDelegate(call.execute()); + } + + /** + * Get a 200 to test a valid base uri. + * + * @param vault The vault name, e.g. https://myvault + * @param secret Secret value. + * @param keyName The key name with value 'key1'. + * @param keyVersion The key version. Default value 'v1'. + * @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 getEmptyAsync(String vault, String secret, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vault == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vault is required and cannot be null.")); + return null; + } + if (secret == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secret is required and cannot be null.")); + return null; + } + if (this.client.getDnsSuffix() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getDnsSuffix() is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.client.getSubscriptionId() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getSubscriptionId() is required and cannot be null.")); + return null; + } + this.client.getBaseUrl().set("{vault}", vault); + this.client.getBaseUrl().set("{secret}", secret); + this.client.getBaseUrl().set("{dnsSuffix}", this.client.getDnsSuffix()); + Call call = service.getEmpty(keyName, this.client.getSubscriptionId(), keyVersion); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getEmptyDelegate(response)); + } catch (ErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getEmptyDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException { + return new ServiceResponseBuilder(this.client.getMapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorException.class) + .build(response); + } + +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/Error.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/Error.java new file mode 100644 index 0000000000000..73232cf4ed434 --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/Error.java @@ -0,0 +1,64 @@ +/** + * 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.custombaseurimoreoptions.models; + + +/** + * The Error model. + */ +public class Error { + /** + * The status property. + */ + private Integer status; + + /** + * The message property. + */ + private String message; + + /** + * Get the status value. + * + * @return the status value + */ + public Integer getStatus() { + return this.status; + } + + /** + * Set the status value. + * + * @param status the status value to set + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String getMessage() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + */ + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/ErrorException.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/ErrorException.java new file mode 100644 index 0000000000000..0c4458e200dac --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/ErrorException.java @@ -0,0 +1,89 @@ +/** + * 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.custombaseurimoreoptions.models; + +import com.microsoft.rest.AutoRestException; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with Error information. + */ +public class ErrorException extends AutoRestException { + /** + * Information about the associated HTTP response. + */ + private Response response; + /** + * The actual response body. + */ + private Error body; + /** + * Initializes a new instance of the ErrorException class. + */ + public ErrorException() { } + /** + * Initializes a new instance of the ErrorException class. + * + * @param message The exception message. + */ + public ErrorException(final String message) { + super(message); + } + /** + * Initializes a new instance of the ErrorException class. + * + * @param message the exception message + * @param cause exception that caused this exception to occur + */ + public ErrorException(final String message, final Throwable cause) { + super(message, cause); + } + /** + * Initializes a new instance of the ErrorException class. + * + * @param cause exception that caused this exception to occur + */ + public ErrorException(final Throwable cause) { + super(cause); + } + /** + * Gets information about the associated HTTP response. + * + * @return the HTTP response + */ + public Response getResponse() { + return response; + } + /** + * Gets the HTTP response body. + * + * @return the response body + */ + public Error getBody() { + return body; + } + /** + * Sets the HTTP response. + * + * @param response the HTTP response + */ + public void setResponse(Response response) { + this.response = response; + } + /** + * Sets the HTTP response body. + * + * @param body the response body + */ + public void setBody(Error body) { + this.body = body; + } +} diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/package-info.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/package-info.java new file mode 100644 index 0000000000000..b5c9a91ec97d8 --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/models/package-info.java @@ -0,0 +1,13 @@ +// 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. + +/** + * This package contains the model classes for AutoRestParameterizedCustomHostTestClient. + * Test Infrastructure for AutoRest. + */ +package fixtures.custombaseurimoreoptions.models; diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/package-info.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/package-info.java new file mode 100644 index 0000000000000..a6434083eb1c5 --- /dev/null +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseurimoreoptions/package-info.java @@ -0,0 +1,13 @@ +// 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. + +/** + * This package contains the classes for AutoRestParameterizedCustomHostTestClient. + * Test Infrastructure for AutoRest. + */ +package fixtures.custombaseurimoreoptions; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureCustomBaseUri.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureCustomBaseUri.js index 70960a0e0895e..c50f1f521a66d 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureCustomBaseUri.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/azureCustomBaseUri.js @@ -18,7 +18,8 @@ var clientOptions = {}; describe('nodejs', function () { describe('Custom BaseUri Client', function () { - var testClient = new customBaseUriClient(credentials, 'host:3000', clientOptions); + clientOptions.host = 'host:3000'; + var testClient = new customBaseUriClient(credentials, clientOptions); it('should return 200', function (done) { testClient.paths.getEmpty('local', function (error, result, request, response) { should.not.exist(error); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/models/durationWrapper.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/models/durationWrapper.js index 3eba03688006e..05c4a93c4a750 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/models/durationWrapper.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/models/durationWrapper.js @@ -10,8 +10,6 @@ 'use strict'; -var moment = require('moment'); - /** * @class * Initializes a new instance of the DurationWrapper class. diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts index 59cea5a89b930..5092268e0db7c 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts @@ -19,8 +19,6 @@ declare class AutoRestParameterizedHostTestClient { * * @param {credentials} credentials - Gets Azure subscription credentials. * - * @param {string} host - A string value that is used as a global part of the parameterized host - * * @param {object} [options] - The parameter options * * @param {Array} [options.filters] - Filters to be added to the request pipeline @@ -30,6 +28,8 @@ declare class AutoRestParameterizedHostTestClient { * * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * + * @param {string} [options.host] - A string value that is used as a global part of the parameterized host + * * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. * * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. @@ -37,7 +37,7 @@ declare class AutoRestParameterizedHostTestClient { * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * */ - constructor(credentials: ServiceClientCredentials, host: string, options: ServiceClientOptions); + constructor(credentials: ServiceClientCredentials, options: ServiceClientOptions); credentials: ServiceClientCredentials; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js index 9c7f803b703ef..43f7a3c828168 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js @@ -29,8 +29,6 @@ var operations = require('./operations'); * * @param {credentials} credentials - Gets Azure subscription credentials. * - * @param {string} host - A string value that is used as a global part of the parameterized host - * * @param {object} [options] - The parameter options * * @param {Array} [options.filters] - Filters to be added to the request pipeline @@ -40,6 +38,8 @@ var operations = require('./operations'); * * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * + * @param {string} [options.host] - A string value that is used as a global part of the parameterized host + * * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. * * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. @@ -47,7 +47,7 @@ var operations = require('./operations'); * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * */ -function AutoRestParameterizedHostTestClient(credentials, host, options) { +function AutoRestParameterizedHostTestClient(credentials, options) { this.host = 'host'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; @@ -55,19 +55,16 @@ function AutoRestParameterizedHostTestClient(credentials, host, options) { if (credentials === null || credentials === undefined) { throw new Error('\'credentials\' cannot be null.'); } - if (host === null || host === undefined) { - throw new Error('\'host\' cannot be null.'); - } if (!options) options = {}; AutoRestParameterizedHostTestClient['super_'].call(this, credentials, options); - if (!this.baseUri) { - this.baseUri = 'http://{accountName}{host}'; - } + this.baseUri = 'http://{accountName}{host}'; this.credentials = credentials; - this.host = host; + if(options.host !== null && options.host !== undefined) { + this.host = options.host; + } if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { this.acceptLanguage = options.acceptLanguage; } diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplate.cshtml b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplate.cshtml index cdfc5a425ea54..e0639dec63e0b 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplate.cshtml +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplate.cshtml @@ -40,8 +40,8 @@ var ServiceClient = msRestAzure.AzureServiceClient; @:var operations = require('./operations'); } @EmptyLine -@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);} -@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);} +@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));} +@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);} /** * @@class * Initializes a new instance of the @Model.Name class. @@ -73,7 +73,7 @@ var ServiceClient = msRestAzure.AzureServiceClient; @: * } */ -function @(Model.Name)(@(Model.RequiredConstructorParameters), options) { +function @(Model.Name)(@(!string.IsNullOrEmpty(Model.RequiredConstructorParameters) ? Model.RequiredConstructorParameters + ", " : "")options) { @foreach (var property in Model.Properties.Where(p => p.DefaultValue != null)) { @:this.@(property.Name) = @(property.DefaultValue); @@ -91,11 +91,16 @@ function @(Model.Name)(@(Model.RequiredConstructorParameters), options) { @if(!Model.IsCustomBaseUri) { @:this.baseUri = baseUri; + @:if (!this.baseUri) { + @:this.baseUri = '@Model.BaseUrl'; + @:} +} +else +{ + @:this.baseUri = '@Model.BaseUrl'; } - if (!this.baseUri) { - this.baseUri = '@Model.BaseUrl'; - } + @foreach (var param in requiredParameters) { @: this.@(param.Name) = @(param.Name); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplateTS.cshtml b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplateTS.cshtml index b7142e35c49e4..5448c378c401c 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplateTS.cshtml +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/AzureServiceClientTemplateTS.cshtml @@ -18,8 +18,8 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback, ServiceClientCre } @EmptyLine declare class @(Model.Name) { - @{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);} - @{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);} + @{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));} + @{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);} /** * @@class * Initializes a new instance of the @Model.Name class. @@ -52,7 +52,7 @@ declare class @(Model.Name) { @: * } */ - constructor(@(Model.RequiredConstructorParametersTS), options: ServiceClientOptions); + constructor(@(!string.IsNullOrEmpty(Model.RequiredConstructorParametersTS) ? Model.RequiredConstructorParametersTS + ", " : "")options: ServiceClientOptions); @foreach (var property in Model.Properties) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/PageModelTemplate.cshtml b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/PageModelTemplate.cshtml index 4f714041a98a5..36056f6225333 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/PageModelTemplate.cshtml +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/Templates/PageModelTemplate.cshtml @@ -14,11 +14,6 @@ @EmptyLine var util = require('util'); @EmptyLine -@if (Model.ContainsDurationProperty()) -{ -@:var moment = require('moment'); -@EmptyLine -} /** * @@class * Initializes a new instance of the @(Model.Name) class. diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/AcceptanceTests/acceptanceTests.ts b/AutoRest/Generators/NodeJS/NodeJS.Tests/AcceptanceTests/acceptanceTests.ts index 52e27445dc45e..0a81b3420068b 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/AcceptanceTests/acceptanceTests.ts +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/AcceptanceTests/acceptanceTests.ts @@ -32,7 +32,7 @@ import dictionaryModels = require('../Expected/AcceptanceTests/BodyDictionary/mo import httpClient = require('../Expected/AcceptanceTests/Http/autoRestHttpInfrastructureTestService'); import formDataClient = require('../Expected/AcceptanceTests/BodyFormData/autoRestSwaggerBATFormDataService'); import customBaseUriClient = require('../Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient'); - +import customBaseUriClientMoreOptions = require('../Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient'); var dummyToken = 'dummy12321343423'; var credentials = new msRest.TokenCredentials(dummyToken); @@ -65,7 +65,10 @@ describe('nodejs', function () { describe('Swagger BAT', function () { describe('Custom BaseUri Client', function () { - var testClient = new customBaseUriClient('host:3000', clientOptions); + var customOptions = { + host: 'host:3000' + }; + var testClient = new customBaseUriClient(customOptions); it('should return 200', function (done) { testClient.paths.getEmpty('local', function (error, result, request, response) { should.not.exist(error); @@ -91,6 +94,19 @@ describe('nodejs', function () { }); }); }); + describe('Custom BaseUri Client with more options', function () { + var customOptions = { + dnsSuffix: 'host:3000' + }; + var testClient = new customBaseUriClientMoreOptions('test12', customOptions); + it('should return 200', function (done) { + testClient.paths.getEmpty('http://lo','cal', 'key1', function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + done(); + }); + }); + }); describe('Bool Client', function () { var testClient = new boolClient(baseUri, clientOptions); it('should get valid boolean values', function (done) { diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/BodyComplex/models/durationWrapper.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/BodyComplex/models/durationWrapper.js index 3eba03688006e..05c4a93c4a750 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/BodyComplex/models/durationWrapper.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/BodyComplex/models/durationWrapper.js @@ -10,8 +10,6 @@ 'use strict'; -var moment = require('moment'); - /** * @class * Initializes a new instance of the DurationWrapper class. diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts index 7dfd384801704..55373a0e9682c 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.d.ts @@ -17,8 +17,6 @@ declare class AutoRestParameterizedHostTestClient { * Initializes a new instance of the AutoRestParameterizedHostTestClient class. * @constructor * - * @param {string} host - A string value that is used as a global part of the parameterized host - * * @param {object} [options] - The parameter options * * @param {Array} [options.filters] - Filters to be added to the request pipeline @@ -28,8 +26,10 @@ declare class AutoRestParameterizedHostTestClient { * * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * + * @param {string} [options.host] - A string value that is used as a global part of the parameterized host + * */ - constructor(host: string, options: ServiceClientOptions); + constructor(options: ServiceClientOptions); host: string; diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js index 96817a9819895..84e01146a9845 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUri/autoRestParameterizedHostTestClient.js @@ -26,8 +26,6 @@ var operations = require('./operations'); * Initializes a new instance of the AutoRestParameterizedHostTestClient class. * @constructor * - * @param {string} host - A string value that is used as a global part of the parameterized host - * * @param {object} [options] - The parameter options * * @param {Array} [options.filters] - Filters to be added to the request pipeline @@ -37,21 +35,20 @@ var operations = require('./operations'); * * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * + * @param {string} [options.host] - A string value that is used as a global part of the parameterized host + * */ -function AutoRestParameterizedHostTestClient(host, options) { +function AutoRestParameterizedHostTestClient(options) { this.host = 'host'; - if (host === null || host === undefined) { - throw new Error('\'host\' cannot be null.'); - } if (!options) options = {}; AutoRestParameterizedHostTestClient['super_'].call(this, null, options); - if (!this.baseUri) { - this.baseUri = 'http://{accountName}{host}'; - } - this.host = host; + this.baseUri = 'http://{accountName}{host}'; + if(options.host !== null && options.host !== undefined) { + this.host = options.host; + } this.paths = new operations.Paths(this); this.models = models; msRest.addSerializationMixin(this); diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.d.ts b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.d.ts new file mode 100644 index 0000000000000..98c22ab85f4de --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.d.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClientOptions, RequestOptions, ServiceCallback } from 'ms-rest'; +import * as operations from "./operations"; + +declare class AutoRestParameterizedCustomHostTestClient { + /** + * @class + * Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class. + * @constructor + * + * @param {string} subscriptionId - The subscription id with value 'test12'. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.dnsSuffix] - A string value that is used as a global part of the parameterized host. Default value 'host'. + * + */ + constructor(subscriptionId: string, options: ServiceClientOptions); + + subscriptionId: string; + + dnsSuffix: string; + + // Operation groups + paths: operations.Paths; + } + +export = AutoRestParameterizedCustomHostTestClient; diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.js new file mode 100644 index 0000000000000..391f7b50deb38 --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autoRestParameterizedCustomHostTestClient.js @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var util = require('util'); +var msRest = require('ms-rest'); +var ServiceClient = msRest.ServiceClient; + +var models = require('./models'); +var operations = require('./operations'); + +/** + * @class + * Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class. + * @constructor + * + * @param {string} subscriptionId - The subscription id with value 'test12'. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.dnsSuffix] - A string value that is used as a global part of the parameterized host. Default value 'host'. + * + */ +function AutoRestParameterizedCustomHostTestClient(subscriptionId, options) { + this.dnsSuffix = 'host'; + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + AutoRestParameterizedCustomHostTestClient['super_'].call(this, null, options); + this.baseUri = '{vault}{secret}{dnsSuffix}'; + this.subscriptionId = subscriptionId; + + if(options.dnsSuffix !== null && options.dnsSuffix !== undefined) { + this.dnsSuffix = options.dnsSuffix; + } + this.paths = new operations.Paths(this); + this.models = models; + msRest.addSerializationMixin(this); +} + +util.inherits(AutoRestParameterizedCustomHostTestClient, ServiceClient); + +module.exports = AutoRestParameterizedCustomHostTestClient; diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/errorModel.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/errorModel.js new file mode 100644 index 0000000000000..663be0f4aaa8c --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/errorModel.js @@ -0,0 +1,58 @@ +/* + * 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 ErrorModel class. + * @constructor + * @member {number} [status] + * + * @member {string} [message] + * + */ +function ErrorModel() { +} + +/** + * Defines the metadata of ErrorModel + * + * @returns {object} metadata of ErrorModel + * + */ +ErrorModel.prototype.mapper = function () { + return { + required: false, + serializedName: 'Error', + type: { + name: 'Composite', + className: 'ErrorModel', + modelProperties: { + status: { + required: false, + serializedName: 'status', + type: { + name: 'Number' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; +}; + +module.exports = ErrorModel; diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.d.ts b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.d.ts new file mode 100644 index 0000000000000..5405a199a0755 --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.d.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + + +/** + * @class + * Initializes a new instance of the ErrorModel class. + * @constructor + * @member {number} [status] + * + * @member {string} [message] + * + */ +export interface ErrorModel { + status?: number; + message?: string; +} diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.js new file mode 100644 index 0000000000000..3430295d8bd86 --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/models/index.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.ErrorModel = require('./errorModel'); diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.d.ts b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.d.ts new file mode 100644 index 0000000000000..3fa4ea5d9bf14 --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.d.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * Paths + * __NOTE__: An instance of this class is automatically created for an + * instance of the AutoRestParameterizedCustomHostTestClient. + */ +export interface Paths { + + /** + * Get a 200 to test a valid base uri + * + * @param {string} vault The vault name, e.g. https://myvault + * + * @param {string} secret Secret value. + * + * @param {string} keyName The key name with value 'key1'. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.keyVersion] The key version. Default value 'v1'. + * + * @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 + */ + getEmpty(vault: string, secret: string, keyName: string, options: { keyVersion? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + getEmpty(vault: string, secret: string, keyName: string, callback: ServiceCallback): void; +} diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.js new file mode 100644 index 0000000000000..412d88e67668a --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/index.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.Paths = require('./paths'); diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/paths.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/paths.js new file mode 100644 index 0000000000000..dc2c66f05c60e --- /dev/null +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/operations/paths.js @@ -0,0 +1,167 @@ +/* + * 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'); +var msRest = require('ms-rest'); +var WebResource = msRest.WebResource; + +/** + * @class + * Paths + * __NOTE__: An instance of this class is automatically created for an + * instance of the AutoRestParameterizedCustomHostTestClient. + * Initializes a new instance of the Paths class. + * @constructor + * + * @param {AutoRestParameterizedCustomHostTestClient} client Reference to the service client. + */ +function Paths(client) { + this.client = client; +} + +/** + * Get a 200 to test a valid base uri + * + * @param {string} vault The vault name, e.g. https://myvault + * + * @param {string} secret Secret value. + * + * @param {string} keyName The key name with value 'key1'. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.keyVersion] The key version. Default value 'v1'. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +Paths.prototype.getEmpty = function (vault, secret, keyName, 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 keyVersion = (options && options.keyVersion !== undefined) ? options.keyVersion : 'v1'; + // Validate + try { + if (vault === null || vault === undefined || typeof vault.valueOf() !== 'string') { + throw new Error('vault cannot be null or undefined and it must be of type string.'); + } + if (secret === null || secret === undefined || typeof secret.valueOf() !== 'string') { + throw new Error('secret cannot be null or undefined and it must be of type string.'); + } + if (this.client.dnsSuffix === null || this.client.dnsSuffix === undefined || typeof this.client.dnsSuffix.valueOf() !== 'string') { + throw new Error('this.client.dnsSuffix cannot be null or undefined and it must be of type string.'); + } + if (keyName === null || keyName === undefined || typeof keyName.valueOf() !== 'string') { + throw new Error('keyName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (keyVersion !== null && keyVersion !== undefined && typeof keyVersion.valueOf() !== 'string') { + throw new Error('keyVersion must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = this.client.baseUri + + '//customuri/{subscriptionId}/{keyName}'; + requestUrl = requestUrl.replace('{vault}', vault); + requestUrl = requestUrl.replace('{secret}', secret); + requestUrl = requestUrl.replace('{dnsSuffix}', this.client.dnsSuffix); + requestUrl = requestUrl.replace('{keyName}', encodeURIComponent(keyName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + var queryParameters = []; + if (keyVersion !== null && keyVersion !== undefined) { + queryParameters.push('keyVersion=' + encodeURIComponent(keyVersion)); + } + 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(options) { + for(var headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, function (err, response, responseBody) { + if (err) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + var parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + var resultMapper = new client.models['ErrorModel']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = util.format('Error "%s" occurred in deserializing the responseBody ' + + '- "%s" for the default response.', defaultError.message, responseBody); + return callback(error); + } + return callback(error); + } + // Create Result + var result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +}; + + +module.exports = Paths; diff --git a/AutoRest/Generators/NodeJS/NodeJS/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/NodeJS/NodeJS/TemplateModels/ServiceClientTemplateModel.cs index 577a91bd3e147..ec34d6af04247 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/NodeJS/NodeJS/TemplateModels/ServiceClientTemplateModel.cs @@ -154,13 +154,18 @@ public string RequiredConstructorParameters get { var requireParams = new List(); - this.Properties.Where(p => p.IsRequired && !p.IsConstant) + this.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue)) .ForEach(p => requireParams.Add(p.Name.ToCamelCase())); if (!IsCustomBaseUri) { requireParams.Add("baseUri"); } + if(requireParams == null || requireParams.Count == 0) + { + return string.Empty; + } + return string.Join(", ", requireParams); } } @@ -174,7 +179,7 @@ public string RequiredConstructorParametersTS { bool first = true; foreach (var p in this.Properties) { - if (!p.IsRequired || p.IsConstant) + if (!p.IsRequired || p.IsConstant || (p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue))) continue; if (!first) diff --git a/AutoRest/Generators/NodeJS/NodeJS/Templates/ModelTemplate.cshtml b/AutoRest/Generators/NodeJS/NodeJS/Templates/ModelTemplate.cshtml index 75c9384491c78..9ab35ed94e1e0 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/Templates/ModelTemplate.cshtml +++ b/AutoRest/Generators/NodeJS/NodeJS/Templates/ModelTemplate.cshtml @@ -20,11 +20,6 @@ @:var util = require('util'); @EmptyLine } -@if (Model.ContainsDurationProperty()) -{ -@:var moment = require('moment'); -@EmptyLine -} /** * @@class * Initializes a new instance of the @(Model.Name) class. diff --git a/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplate.cshtml b/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplate.cshtml index 07092323c73f6..055038401726b 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplate.cshtml +++ b/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplate.cshtml @@ -37,8 +37,8 @@ var ServiceClient = msRest.ServiceClient; @:var operations = require('./operations'); } @EmptyLine -@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);} -@{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);} +@{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));} +@{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);} /** * @@class * Initializes a new instance of the @Model.Name class. @@ -71,7 +71,7 @@ var ServiceClient = msRest.ServiceClient; @: * } */ -function @(Model.Name)(@(Model.RequiredConstructorParameters), options) { +function @(Model.Name)(@(!string.IsNullOrEmpty(Model.RequiredConstructorParameters) ? Model.RequiredConstructorParameters + ", ": "")options) { @foreach (var property in Model.Properties.Where(p => p.DefaultValue != null)) { @:this.@(property.Name) = @(property.DefaultValue); @@ -91,11 +91,17 @@ function @(Model.Name)(@(Model.RequiredConstructorParameters), options) { @if(!Model.IsCustomBaseUri) { @:this.baseUri = baseUri; + + @:if (!this.baseUri) { + @:this.baseUri = '@Model.BaseUrl'; + @:} +} +else +{ + @:this.baseUri = '@Model.BaseUrl'; } - if (!this.baseUri) { - this.baseUri = '@Model.BaseUrl'; - } + @foreach (var param in requiredParameters) { diff --git a/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplateTS.cshtml b/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplateTS.cshtml index 61edf0e006279..c9e479a3c95e4 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplateTS.cshtml +++ b/AutoRest/Generators/NodeJS/NodeJS/Templates/ServiceClientTemplateTS.cshtml @@ -18,8 +18,8 @@ import { ServiceClientOptions, RequestOptions, ServiceCallback } from 'ms-rest'; } @EmptyLine declare class @(Model.Name) { - @{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant);} - @{var optionalParameters = Model.Properties.Where(p => !p.IsRequired && !p.IsConstant);} + @{var requiredParameters = Model.Properties.Where(p => p.IsRequired && !p.IsConstant && string.IsNullOrEmpty(p.DefaultValue));} + @{var optionalParameters = Model.Properties.Where(p => (!p.IsRequired || p.IsRequired && !string.IsNullOrEmpty(p.DefaultValue)) && !p.IsConstant);} /** * @@class * Initializes a new instance of the @Model.Name class. @@ -52,7 +52,7 @@ declare class @(Model.Name) { @: * } */ - constructor(@(Model.RequiredConstructorParametersTS), options: ServiceClientOptions); + constructor(@(!string.IsNullOrEmpty(Model.RequiredConstructorParametersTS) ? Model.RequiredConstructorParametersTS + ", ": "")options: ServiceClientOptions); @foreach (var property in Model.Properties) { diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py index bceee986fdda8..668b135381e1f 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py @@ -43,7 +43,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'https://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message 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 386a34a84a195..251a4cda74c35 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/auto_rest_parameter_grouping_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/auto_rest_parameter_grouping_test_service.py index b8bae0b1b5228..13e63f9569c81 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/auto_rest_parameter_grouping_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/auto_rest_parameter_grouping_test_service.py @@ -43,7 +43,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'https://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py index bd178f8128ba4..0a3174e49ea52 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py @@ -22,6 +22,6 @@ class FirstParameterGroup(Model): :type query_one: int """ - def __init__(self, header_one=None, query_one=30, **kwargs): + def __init__(self, header_one=None, query_one=30): self.header_one = header_one self.query_one = query_one diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py index e885a9124d948..d178c7470903e 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py @@ -22,6 +22,6 @@ class ParameterGroupingPostMultiParamGroupsSecondParamGroup(Model): :type query_two: int """ - def __init__(self, header_two=None, query_two=30, **kwargs): + def __init__(self, header_two=None, query_two=30): self.header_two = header_two self.query_two = query_two diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py index a89e6b36d00b3..7368af7d84956 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py @@ -22,6 +22,6 @@ class ParameterGroupingPostOptionalParameters(Model): :type query: int """ - def __init__(self, custom_header=None, query=30, **kwargs): + def __init__(self, custom_header=None, query=30): self.custom_header = custom_header self.query = query diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py index 56ec95284747e..33627d834bdad 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py @@ -31,7 +31,7 @@ class ParameterGroupingPostRequiredParameters(Model): 'path': {'required': True}, } - def __init__(self, body, path, custom_header=None, query=30, **kwargs): + def __init__(self, body, path, custom_header=None, query=30): self.body = body self.custom_header = custom_header self.query = query 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 188c79aaea4bf..2e0910c9bcdeb 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/auto_rest_report_service_for_azure.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/auto_rest_report_service_for_azure.py index b37530e7d7985..c02088e43b1a4 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/auto_rest_report_service_for_azure.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/auto_rest_report_service_for_azure.py @@ -44,7 +44,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message 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 b088cbdc514b9..762429f51c290 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py index 3a806d13f53fc..74f09db9d3400 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py @@ -44,7 +44,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/flattened_product.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/flattened_product.py index 019aa228b5d07..5b5b7ea2e4c04 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/flattened_product.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/flattened_product.py @@ -44,8 +44,8 @@ class FlattenedProduct(Resource): 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, pname=None, lsize=None, provisioning_state=None, **kwargs): - super(FlattenedProduct, self).__init__(id=id, type=type, tags=tags, location=location, name=name, **kwargs) + def __init__(self, id=None, type=None, tags=None, location=None, name=None, pname=None, lsize=None, provisioning_state=None): + super(FlattenedProduct, self).__init__(id=id, type=type, tags=tags, location=location, name=name) self.pname = pname self.lsize = lsize self.provisioning_state = provisioning_state diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource.py index c2e81e8035ee3..ccc46d79f60ce 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource.py @@ -35,7 +35,7 @@ class Resource(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, **kwargs): + def __init__(self, id=None, type=None, tags=None, location=None, name=None): self.id = id self.type = type self.tags = tags diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource_collection.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource_collection.py index ce97251d6b01a..4c59a75395942 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource_collection.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/models/resource_collection.py @@ -31,7 +31,7 @@ class ResourceCollection(Model): 'dictionaryofresources': {'key': 'dictionaryofresources', 'type': '{FlattenedProduct}'}, } - def __init__(self, productresource=None, arrayofresources=None, dictionaryofresources=None, **kwargs): + def __init__(self, productresource=None, arrayofresources=None, dictionaryofresources=None): self.productresource = productresource self.arrayofresources = arrayofresources self.dictionaryofresources = dictionaryofresources 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 93b7b7f8b4bd8..d4003cb22d3fd 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/auto_rest_azure_special_parameters_test_client.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/auto_rest_azure_special_parameters_test_client.py index cc2d96c0ce719..95f2d47d0fb58 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/auto_rest_azure_special_parameters_test_client.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/auto_rest_azure_special_parameters_test_client.py @@ -56,9 +56,15 @@ def __init__( self, credentials, subscription_id, api_version='2015-07-01-preview', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: - raise ValueError('subscription_id must not be None.') + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") + if api_version is not None and not isinstance(api_version, str): + raise TypeError("Optional parameter 'api_version' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/error.py index b4ab713953874..e9ef780e3aefa 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/error.py @@ -30,7 +30,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, constant_id=None, message=None, **kwargs): + def __init__(self, status=None, constant_id=None, message=None): self.status = status self.constant_id = constant_id self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/odata_filter.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/odata_filter.py index a0604d9f6045b..16c1f6545d148 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/odata_filter.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/models/odata_filter.py @@ -26,6 +26,6 @@ class OdataFilter(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, name=None, **kwargs): + def __init__(self, id=None, name=None): self.id = id self.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 581909f4464b6..a23f56d19161d 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py index ce9c7112afaf5..79e862f82db73 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py @@ -45,9 +45,13 @@ def __init__( self, credentials, host, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") if host is None: - raise ValueError('host must not be None.') + raise ValueError("Parameter 'host' must not be None.") + if not isinstance(host, str): + raise TypeError("Parameter 'host' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") base_url = 'http://{accountName}{host}' super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(base_url, filepath) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message 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 d7a4a945847f1..b58762d14bf16 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/auto_rest_head_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/auto_rest_head_test_service.py index 85044ec1cbcc4..fc86a3308cb2e 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/auto_rest_head_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/auto_rest_head_test_service.py @@ -42,7 +42,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' 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 8fd8508a288a8..e11e2311eb413 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/auto_rest_head_exception_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/auto_rest_head_exception_test_service.py index e7531777378d2..d9745572729ef 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/auto_rest_head_exception_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/auto_rest_head_exception_test_service.py @@ -42,7 +42,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' 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 94a2cb8cb8860..eea7127ecba39 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/auto_rest_long_running_operation_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/auto_rest_long_running_operation_test_service.py index 718b1114d10af..be1ddc0cc63c0 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/auto_rest_long_running_operation_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/auto_rest_long_running_operation_test_service.py @@ -46,7 +46,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result.py index 21fd4883dc37e..2ded58b2f5920 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result.py @@ -29,6 +29,6 @@ class OperationResult(Model): 'error': {'key': 'error', 'type': 'OperationResultError'}, } - def __init__(self, status=None, error=None, **kwargs): + def __init__(self, status=None, error=None): self.status = status self.error = error diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result_error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result_error.py index 974649001b44e..22dab4495c979 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result_error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/operation_result_error.py @@ -26,6 +26,6 @@ class OperationResultError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, code=None, message=None, **kwargs): + def __init__(self, code=None, message=None): self.code = code self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/product.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/product.py index db52ee8ddc946..6f322f37b09fc 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/product.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/product.py @@ -43,7 +43,7 @@ class Product(Resource): 'provisioning_state_values': {'key': 'properties.provisioningStateValues', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, provisioning_state=None, provisioning_state_values=None, **kwargs): - super(Product, self).__init__(id=id, type=type, tags=tags, location=location, name=name, **kwargs) + def __init__(self, id=None, type=None, tags=None, location=None, name=None, provisioning_state=None, provisioning_state_values=None): + super(Product, self).__init__(id=id, type=type, tags=tags, location=location, name=name) self.provisioning_state = provisioning_state self.provisioning_state_values = provisioning_state_values diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/resource.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/resource.py index c2e81e8035ee3..ccc46d79f60ce 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/resource.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/resource.py @@ -35,7 +35,7 @@ class Resource(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, **kwargs): + def __init__(self, id=None, type=None, tags=None, location=None, name=None): self.id = id self.type = type self.tags = tags diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sku.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sku.py index 42b14cd43755d..d7f35d777f639 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sku.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sku.py @@ -26,6 +26,6 @@ class Sku(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, name=None, id=None, **kwargs): + def __init__(self, name=None, id=None): self.name = name self.id = id diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_product.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_product.py index a0bc26f58f22e..099f79ecdc9de 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_product.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_product.py @@ -31,7 +31,7 @@ class SubProduct(SubResource): 'provisioning_state_values': {'key': 'properties.provisioningStateValues', 'type': 'str'}, } - def __init__(self, id=None, provisioning_state=None, provisioning_state_values=None, **kwargs): - super(SubProduct, self).__init__(id=id, **kwargs) + def __init__(self, id=None, provisioning_state=None, provisioning_state_values=None): + super(SubProduct, self).__init__(id=id) self.provisioning_state = provisioning_state self.provisioning_state_values = provisioning_state_values diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_resource.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_resource.py index 83b7f418cbe93..46ce23db785ac 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_resource.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/models/sub_resource.py @@ -23,5 +23,5 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, id=None, **kwargs): + def __init__(self, id=None): self.id = id 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 3d6569fed9a9e..6efdcd0d3ea4e 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/auto_rest_paging_test_service.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/auto_rest_paging_test_service.py index 532adc38d5acc..e3cf9310642ed 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/auto_rest_paging_test_service.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/auto_rest_paging_test_service.py @@ -43,7 +43,9 @@ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/operation_result.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/operation_result.py index 13b86a98343d8..e0af748f82c9f 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/operation_result.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/operation_result.py @@ -25,5 +25,5 @@ class OperationResult(Model): 'status': {'key': 'status', 'type': 'str'}, } - def __init__(self, status=None, **kwargs): + def __init__(self, status=None): self.status = status diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py index c91f754fee26f..c776b4da879d7 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py @@ -25,6 +25,6 @@ class PagingGetMultiplePagesOptions(Model): :type timeout: int """ - def __init__(self, maxresults=None, timeout=30, **kwargs): + 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/paging_get_multiple_pages_with_offset_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py index cdb588109cda7..57650f8519648 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py @@ -31,7 +31,7 @@ class PagingGetMultiplePagesWithOffsetOptions(Model): 'offset': {'required': True}, } - def __init__(self, offset, maxresults=None, timeout=30, **kwargs): + def __init__(self, offset, maxresults=None, timeout=30): self.maxresults = maxresults self.offset = offset self.timeout = timeout diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product.py index d9babb6925957..f019f46d72e5a 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product.py @@ -24,5 +24,5 @@ class Product(Model): 'properties': {'key': 'properties', 'type': 'ProductProperties'}, } - def __init__(self, properties=None, **kwargs): + def __init__(self, properties=None): self.properties = properties diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_properties.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_properties.py index 2924fa9464303..4db1d4204a78d 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_properties.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/product_properties.py @@ -26,6 +26,6 @@ class ProductProperties(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, name=None, **kwargs): + def __init__(self, id=None, name=None): self.id = id self.name = name 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 a02653a9cb33b..b8c042a69efb9 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] 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 100c1f03a42f3..7e7b4160e02e1 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/bar.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/bar.py index dd61b74f50851..09c2ed766ed61 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/bar.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/bar.py @@ -26,5 +26,5 @@ class Bar(Model): 'recursive_point': {'key': 'RecursivePoint', 'type': 'Endpoints'}, } - def __init__(self, recursive_point=None, **kwargs): + def __init__(self, recursive_point=None): self.recursive_point = recursive_point 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 2626b7d6d9408..cc1c87848bdf4 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 @@ -35,7 +35,7 @@ class CheckNameAvailabilityResult(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, name_available=None, reason=None, message=None, **kwargs): + def __init__(self, name_available=None, reason=None, message=None): self.name_available = name_available self.reason = reason self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/custom_domain.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/custom_domain.py index e94b86210a007..f23bf8e6696ec 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/custom_domain.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/custom_domain.py @@ -30,6 +30,6 @@ class CustomDomain(Model): 'use_sub_domain': {'key': 'useSubDomain', 'type': 'bool'}, } - def __init__(self, name=None, use_sub_domain=None, **kwargs): + def __init__(self, name=None, use_sub_domain=None): self.name = name self.use_sub_domain = use_sub_domain diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/endpoints.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/endpoints.py index 18e67db15f0e1..898527a5c8db1 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/endpoints.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/endpoints.py @@ -39,7 +39,7 @@ class Endpoints(Model): 'foo_point': {'key': 'FooPoint', 'type': 'Foo'}, } - def __init__(self, blob=None, queue=None, table=None, dummy_end_point=None, foo_point=None, **kwargs): + def __init__(self, blob=None, queue=None, table=None, dummy_end_point=None, foo_point=None): self.blob = blob self.queue = queue self.table = table 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 91428f1689ace..2de0ad72c8366 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 @@ -26,5 +26,5 @@ class Foo(Model): 'bar_point': {'key': 'Bar.Point', 'type': 'Bar'}, } - def __init__(self, bar_point=None, **kwargs): + def __init__(self, bar_point=None): self.bar_point = bar_point diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/resource.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/resource.py index d9358ccfb3f05..9025ae9819072 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/resource.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/resource.py @@ -39,7 +39,7 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, location, id=None, name=None, type=None, tags=None, **kwargs): + def __init__(self, location, id=None, name=None, type=None, tags=None): self.id = id self.name = name self.type = type 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 b565b7120cee1..3268320474a92 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 @@ -99,8 +99,8 @@ class StorageAccount(Resource): 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, } - def __init__(self, location, id=None, name=None, type=None, tags=None, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None, **kwargs): - super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs) + def __init__(self, location, id=None, name=None, type=None, tags=None, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None): + super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags) self.provisioning_state = provisioning_state self.account_type = account_type self.primary_endpoints = primary_endpoints diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_check_name_availability_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_check_name_availability_parameters.py index 7fd37db107159..3874804d1acce 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_check_name_availability_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_check_name_availability_parameters.py @@ -30,6 +30,6 @@ class StorageAccountCheckNameAvailabilityParameters(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, name, type="Microsoft.Storage/storageAccounts", **kwargs): + def __init__(self, name, type="Microsoft.Storage/storageAccounts"): self.name = name self.type = type 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 e4de00fde6c84..449f6c502135a 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 @@ -45,6 +45,6 @@ class StorageAccountCreateParameters(Resource): 'account_type': {'key': 'properties.accountType', 'type': 'AccountType'}, } - def __init__(self, location, id=None, name=None, type=None, tags=None, account_type=None, **kwargs): - super(StorageAccountCreateParameters, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs) + def __init__(self, location, id=None, name=None, type=None, tags=None, account_type=None): + super(StorageAccountCreateParameters, self).__init__(id=id, name=name, type=type, location=location, tags=tags) self.account_type = account_type diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_keys.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_keys.py index 6a3d1413b9f3d..6a49f862ea08c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_keys.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_keys.py @@ -27,6 +27,6 @@ class StorageAccountKeys(Model): 'key2': {'key': 'key2', 'type': 'str'}, } - def __init__(self, key1=None, key2=None, **kwargs): + def __init__(self, key1=None, key2=None): self.key1 = key1 self.key2 = key2 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 f4c0bd5893004..7fe2da5d56729 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 @@ -23,5 +23,5 @@ class StorageAccountRegenerateKeyParameters(Model): 'key_name': {'key': 'keyName', 'type': 'KeyName'}, } - def __init__(self, key_name=None, **kwargs): + def __init__(self, key_name=None): self.key_name = key_name 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 1a4b634650561..5975e56879436 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 @@ -54,7 +54,7 @@ class StorageAccountUpdateParameters(Resource): 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, } - def __init__(self, location, id=None, name=None, type=None, tags=None, account_type=None, custom_domain=None, **kwargs): - super(StorageAccountUpdateParameters, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs) + def __init__(self, location, id=None, name=None, type=None, tags=None, account_type=None, custom_domain=None): + super(StorageAccountUpdateParameters, self).__init__(id=id, name=name, type=type, location=location, tags=tags) self.account_type = account_type self.custom_domain = custom_domain diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/sub_resource.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/sub_resource.py index 4daf061642fbf..676b7409deec4 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/sub_resource.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/sub_resource.py @@ -23,5 +23,5 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, id=None, **kwargs): + def __init__(self, id=None): self.id = id 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 3be6b28966e34..53d96b70adf16 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 @@ -38,7 +38,7 @@ class Usage(Model): 'name': {'key': 'name', 'type': 'UsageName'}, } - def __init__(self, unit=None, current_value=None, limit=None, name=None, **kwargs): + def __init__(self, unit=None, current_value=None, limit=None, name=None): self.unit = unit self.current_value = current_value self.limit = limit diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_list_result.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_list_result.py index bb868e0c1633d..58bcc17497530 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_list_result.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_list_result.py @@ -25,5 +25,5 @@ class UsageListResult(Model): 'value': {'key': 'value', 'type': '[Usage]'}, } - def __init__(self, value=None, **kwargs): + def __init__(self, value=None): self.value = value diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_name.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_name.py index 920db4d98eeeb..91e050893c0f9 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_name.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/usage_name.py @@ -28,6 +28,6 @@ class UsageName(Model): 'localized_value': {'key': 'localizedValue', 'type': 'str'}, } - def __init__(self, value=None, localized_value=None, **kwargs): + def __init__(self, value=None, localized_value=None): self.value = value self.localized_value = localized_value diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/storage_management_client.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/storage_management_client.py index cd2c457915195..1334ec94142ec 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/storage_management_client.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/storage_management_client.py @@ -50,9 +50,15 @@ def __init__( self, credentials, subscription_id, api_version='2015-05-01-preview', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: - raise ValueError('subscription_id must not be None.') + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") + if api_version is not None and not isinstance(api_version, str): + raise TypeError("Optional parameter 'api_version' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'https://management.azure.com' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/microsoft_azure_test_url.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/microsoft_azure_test_url.py index 99e3bc1f4ce98..d16f3f25706a6 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/microsoft_azure_test_url.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/microsoft_azure_test_url.py @@ -47,9 +47,15 @@ def __init__( self, credentials, subscription_id, api_version='2014-04-01-preview', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: - raise ValueError('subscription_id must not be None.') + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") + if api_version is not None and not isinstance(api_version, str): + raise TypeError("Optional parameter 'api_version' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'https://management.azure.com/' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/error.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/error.py index e85f2c415d577..9b230ca9dee62 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/error.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, code=None, message=None, **kwargs): + def __init__(self, code=None, message=None): self.code = code self.message = message diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/sample_resource_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/sample_resource_group.py index f2a334ff424c4..19fa537a1bea8 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/sample_resource_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/models/sample_resource_group.py @@ -26,6 +26,6 @@ class SampleResourceGroup(Model): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, name=None, location=None, **kwargs): + def __init__(self, name=None, location=None): self.name = name self.location = location 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 0d026fe2b27f5..a0eeb22b2beda 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs index fb90e029585e1..0ad15558928b5 100644 --- a/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs +++ b/AutoRest/Generators/Python/Azure.Python/AzurePythonCodeGenerator.cs @@ -19,7 +19,7 @@ namespace Microsoft.Rest.Generator.Azure.Python { public class AzurePythonCodeGenerator : PythonCodeGenerator { - private const string ClientRuntimePackage = "msrestazure version 0.1.0"; + private const string ClientRuntimePackage = "msrestazure version 0.2.1"; // page extensions class dictionary. private IList pageModels; diff --git a/AutoRest/Generators/Python/Azure.Python/TemplateModels/AzureServiceClientTemplateModel.cs b/AutoRest/Generators/Python/Azure.Python/TemplateModels/AzureServiceClientTemplateModel.cs index 145dbeb3a79ae..3c0cfcbf8160c 100644 --- a/AutoRest/Generators/Python/Azure.Python/TemplateModels/AzureServiceClientTemplateModel.cs +++ b/AutoRest/Generators/Python/Azure.Python/TemplateModels/AzureServiceClientTemplateModel.cs @@ -97,7 +97,7 @@ public override string SetupRequires { get { - return "\"msrest>=0.1.0\", \"msrestazure>=0.1.0\""; + return "\"msrest>=0.2.0\", \"msrestazure>=0.2.1\""; } } diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py index cc7fb8d0f5eb7..c45c3e0db6836 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py @@ -53,24 +53,21 @@ class FileTests(unittest.TestCase): def test_files(self): config = AutoRestSwaggerBATFileServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level config.connection.data_block_size = 1000 client = AutoRestSwaggerBATFileService(config) - def test_callback(data, response, progress = [0], is_response_streamed=None): + def test_callback(data, response, progress=[0]): self.assertTrue(len(data) > 0) - if not is_response_streamed: - self.assertFalse(response._content_consumed) + self.assertIsNotNone(response) + self.assertFalse(response._content_consumed) + total = float(response.headers['Content-Length']) + if total < 4096: progress[0] += len(data) - total = float(response.headers['Content-Length']) print("Downloading... {}%".format(int(progress[0]*100/total))) - self.assertIsNotNone(response) file_length = 0 with io.BytesIO() as file_handle: - - stream = client.files.get_file(callback=lambda x, response, progress=[0] : - test_callback(x, response, progress, False)) + stream = client.files.get_file(callback=test_callback) for data in stream: file_length += len(data) @@ -86,11 +83,10 @@ def test_callback(data, response, progress = [0], is_response_streamed=None): sample_data = hash(data.read()) self.assertEqual(sample_data, hash(file_handle.getvalue())) + config.connection.data_block_size = 4096 file_length = 0 with io.BytesIO() as file_handle: - - stream = client.files.get_empty_file(callback=lambda x, response, progress=[0] : - test_callback(x, response, progress, False)) + stream = client.files.get_empty_file(callback=test_callback) for data in stream: file_length += len(data) @@ -98,34 +94,34 @@ def test_callback(data, response, progress = [0], is_response_streamed=None): self.assertEqual(file_length, 0) - #file_length = 0 - #stream = client.files.get_file_large(callback=lambda x, response, progress=[0] : - # test_callback(x, response, progress, True)) - #for data in stream: - # file_length += len(data) + def add_headers(adapter, request, response, *args, **kwargs): + response.headers['Content-Length'] = str(3000 * 1024 * 1024) - #self.assertEqual(file_length, 3000 * 1024 * 1024) + file_length = 0 + client._client.add_hook('response', add_headers) + stream = client.files.get_file_large(callback=test_callback) + for data in stream: + file_length += len(data) + + self.assertEqual(file_length, 3000 * 1024 * 1024) def test_files_raw(self): - def test_callback(data, response, progress = [0], is_response_streamed=None): + def test_callback(data, response, progress=[0]): self.assertTrue(len(data) > 0) - if not is_response_streamed: - self.assertFalse(response._content_consumed) + self.assertIsNotNone(response) + self.assertFalse(response._content_consumed) + total = float(response.headers.get('Content-Length', 0)) + if total: progress[0] += len(data) - total = float(response.headers['Content-Length']) print("Downloading... {}%".format(int(progress[0]*100/total))) - self.assertIsNotNone(response) config = AutoRestSwaggerBATFileServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level client = AutoRestSwaggerBATFileService(config) file_length = 0 with io.BytesIO() as file_handle: - - response = client.files.get_file(raw=True, callback=lambda x, response, progress=[0] : - test_callback(x, response, progress, False)) + response = client.files.get_file(raw=True, callback=test_callback) stream = response.output for data in stream: @@ -144,9 +140,7 @@ def test_callback(data, response, progress = [0], is_response_streamed=None): file_length = 0 with io.BytesIO() as file_handle: - - response = client.files.get_empty_file(raw=True, callback=lambda x, response, progress=[0] : - test_callback(x, response, progress, False)) + response = client.files.get_empty_file(raw=True, callback=test_callback) stream = response.output for data in stream: @@ -155,16 +149,5 @@ def test_callback(data, response, progress = [0], is_response_streamed=None): self.assertEqual(file_length, 0) - #file_length = 0 - #response = client.files.get_file_large(raw=True, callback=lambda x, response, progress=[0] : - # test_callback(x, response, progress, True)) - - #stream = response.output - - #for data in stream: - # file_length += len(data) - - #self.assertEqual(file_length, 3000 * 1024 * 1024) - if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py index f18bfdb92aa05..ea1ed1a726f9e 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py @@ -174,7 +174,6 @@ def test_callback(data, response, progress = [0]): with open(self.dummy_file, 'rb') as upload_data: resp = client.formdata.upload_file_via_body(upload_data, callback=test_callback) for r in resp: - print(r) result.write(r) self.assertEqual(result.getvalue().decode(), "Test file") diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py index 05f7b4dcdba4f..3204669e8568c 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py @@ -90,8 +90,9 @@ def test_url_path(self): self.client.paths.get_negative_ten_billion(-10000000000) self.client.paths.get_ten_billion(10000000000) self.client.paths.string_empty("") - #test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] - #self.client.paths.array_csv_in_path(test_array) + + test_array = ["ArrayPath1", r"begin!*'();:@ &=+$,/?#[]end", None, ""] + self.client.paths.array_csv_in_path(test_array) with self.assertRaises(ValidationError): self.client.paths.string_null(None) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py index 3702f08cd4316..ccafa013129b1 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py @@ -53,30 +53,39 @@ def test_ensure_coverage(self): config.log_level = log_level client = AutoRestReportService(config) report = client.get_report() - report['getIntegerOverflow']=1 - report['getIntegerUnderflow']=1 - report['getLongOverflow']=1 - report['getLongUnderflow']=1 - report['getDateInvalid']=1 - report['getDictionaryNullkey']=1 - report['HttpRedirect300Get']=1 - report['FileStreamVeryLarge']=1 + + not_supported = { + 'getIntegerOverflow': 1, + 'getIntegerUnderflow': 1, + 'getLongOverflow': 1, + 'getLongUnderflow': 1, + 'getDateInvalid': 1, + 'getDictionaryNullkey': 1, + 'HttpRedirect300Get': 1, + } # TODO: Support ignore readonly property in http put - report['putComplexReadOnlyPropertyValid']=1 + missing_features_or_bugs = { + 'putComplexReadOnlyPropertyValid': 1, + } + + report.update(not_supported) + report.update(missing_features_or_bugs) + failed = [k for k, v in report.items() if v == 0] + + for s in not_supported.keys(): + print("IGNORING {0}".format(s)) - skipped = [k for k, v in report.items() if v == 0] - manually_marked_successful = [k for k, v in report.items() if v == 2] - for s in manually_marked_successful: - print("SKIPPED {0}".format(s)) + for s in missing_features_or_bugs.keys(): + print("PENDING {0}".format(s)) - for s in skipped: + for s in failed: print("FAILED TO EXECUTE {0}".format(s)) totalTests = len(report) - print ("The test coverage is {0}/{1}.".format(totalTests - len(skipped), totalTests)) + print ("The test coverage is {0}/{1}.".format(totalTests - len(failed), totalTests)) - self.assertEqual(0, len(skipped)) + self.assertEqual(0, len(failed)) if __name__ == '__main__': unittest.main() diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/product.py index 3358c74205436..b74b8ee418307 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/models/product.py @@ -26,6 +26,6 @@ class Product(Model): 'string': {'key': 'string', 'type': 'str'}, } - def __init__(self, integer=None, string=None, **kwargs): + def __init__(self, integer=None, string=None): self.integer = integer self.string = string diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/setup.py index db9a2a12116a5..cf329dfab37c5 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/setup.py index 8058a2eff9ed9..facfec90a0b4c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/setup.py index 38ae3533fae8d..0482b6833f373 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/auto_rest_complex_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/auto_rest_complex_test_service.py index 8ff86db017bbd..3887687ac962c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/auto_rest_complex_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/auto_rest_complex_test_service.py @@ -38,7 +38,9 @@ def __init__( self, api_version, base_url=None, filepath=None): if api_version is None: - raise ValueError('api_version must not be None.') + raise ValueError("Parameter 'api_version' must not be None.") + if not isinstance(api_version, str): + raise TypeError("Parameter 'api_version' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/array_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/array_wrapper.py index 954d370a66c94..df8448a8fbea8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/array_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/array_wrapper.py @@ -23,5 +23,5 @@ class ArrayWrapper(Model): 'array': {'key': 'array', 'type': '[str]'}, } - def __init__(self, array=None, **kwargs): + def __init__(self, array=None): self.array = array diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/basic.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/basic.py index 0f914a9ac9030..83a9721456ac7 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/basic.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/basic.py @@ -30,7 +30,7 @@ class Basic(Model): 'color': {'key': 'color', 'type': 'CMYKColors'}, } - def __init__(self, id=None, name=None, color=None, **kwargs): + def __init__(self, id=None, name=None, color=None): self.id = id self.name = name self.color = color diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/boolean_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/boolean_wrapper.py index 89429bc9bc429..abe1f9cb4e232 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/boolean_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/boolean_wrapper.py @@ -26,6 +26,6 @@ class BooleanWrapper(Model): 'field_false': {'key': 'field_false', 'type': 'bool'}, } - def __init__(self, field_true=None, field_false=None, **kwargs): + def __init__(self, field_true=None, field_false=None): self.field_true = field_true self.field_false = field_false diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/byte_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/byte_wrapper.py index 505b230b7c2f7..56711e83f0787 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/byte_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/byte_wrapper.py @@ -23,5 +23,5 @@ class ByteWrapper(Model): 'field': {'key': 'field', 'type': 'bytearray'}, } - def __init__(self, field=None, **kwargs): + def __init__(self, field=None): self.field = field diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cat.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cat.py index 476c2a0c1d028..15ec946bab6d2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cat.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cat.py @@ -33,7 +33,7 @@ class Cat(Pet): 'hates': {'key': 'hates', 'type': '[Dog]'}, } - def __init__(self, id=None, name=None, color=None, hates=None, **kwargs): - super(Cat, self).__init__(id=id, name=name, **kwargs) + def __init__(self, id=None, name=None, color=None, hates=None): + super(Cat, self).__init__(id=id, name=name) self.color = color self.hates = hates diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cookiecuttershark.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cookiecuttershark.py index ee898dd7d3582..835f078e28c02 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cookiecuttershark.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/cookiecuttershark.py @@ -36,6 +36,6 @@ class Cookiecuttershark(Shark): 'birthday': {'required': True}, } - def __init__(self, length, birthday, species=None, siblings=None, age=None, **kwargs): - super(Cookiecuttershark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) + def __init__(self, length, birthday, species=None, siblings=None, age=None): + super(Cookiecuttershark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday) self.fishtype = 'cookiecuttershark' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/date_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/date_wrapper.py index 03b379e1105c7..d876dc6e736c8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/date_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/date_wrapper.py @@ -26,6 +26,6 @@ class DateWrapper(Model): 'leap': {'key': 'leap', 'type': 'date'}, } - def __init__(self, field=None, leap=None, **kwargs): + def __init__(self, field=None, leap=None): self.field = field self.leap = leap diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetime_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetime_wrapper.py index 74e8645ace21d..c768499e011f9 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetime_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetime_wrapper.py @@ -26,6 +26,6 @@ class DatetimeWrapper(Model): 'now': {'key': 'now', 'type': 'iso-8601'}, } - def __init__(self, field=None, now=None, **kwargs): + def __init__(self, field=None, now=None): self.field = field self.now = now diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetimerfc1123_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetimerfc1123_wrapper.py index 165fdceb85a3c..a0279c5425f7c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetimerfc1123_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/datetimerfc1123_wrapper.py @@ -26,6 +26,6 @@ class Datetimerfc1123Wrapper(Model): 'now': {'key': 'now', 'type': 'rfc-1123'}, } - def __init__(self, field=None, now=None, **kwargs): + def __init__(self, field=None, now=None): self.field = field self.now = now diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dictionary_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dictionary_wrapper.py index e639e709ab1d9..999fec60f3d96 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dictionary_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dictionary_wrapper.py @@ -23,5 +23,5 @@ class DictionaryWrapper(Model): 'default_program': {'key': 'defaultProgram', 'type': '{str}'}, } - def __init__(self, default_program=None, **kwargs): + def __init__(self, default_program=None): self.default_program = default_program diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dog.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dog.py index 69911b3d30437..420352f5b0eb5 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dog.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/dog.py @@ -29,6 +29,6 @@ class Dog(Pet): 'food': {'key': 'food', 'type': 'str'}, } - def __init__(self, id=None, name=None, food=None, **kwargs): - super(Dog, self).__init__(id=id, name=name, **kwargs) + def __init__(self, id=None, name=None, food=None): + super(Dog, self).__init__(id=id, name=name) self.food = food diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/double_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/double_wrapper.py index 5eb718fcc08e7..63f46bd155bd0 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/double_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/double_wrapper.py @@ -29,6 +29,6 @@ class DoubleWrapper(Model): 'field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose': {'key': 'field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose', 'type': 'float'}, } - def __init__(self, field1=None, field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose=None, **kwargs): + def __init__(self, field1=None, field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose=None): self.field1 = field1 self.field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose = field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/duration_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/duration_wrapper.py index ce5cd3ce54403..04cfa5a36c7d2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/duration_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/duration_wrapper.py @@ -23,5 +23,5 @@ class DurationWrapper(Model): 'field': {'key': 'field', 'type': 'duration'}, } - def __init__(self, field=None, **kwargs): + def __init__(self, field=None): self.field = field diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/fish.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/fish.py index f1aea273aefb1..fb83f8e3fa972 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/fish.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/fish.py @@ -42,7 +42,7 @@ class Fish(Model): 'fishtype': {'salmon': 'Salmon', 'shark': 'Shark'} } - def __init__(self, length, species=None, siblings=None, **kwargs): + def __init__(self, length, species=None, siblings=None): self.species = species self.length = length self.siblings = siblings diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/float_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/float_wrapper.py index 52350aacd388a..098ff503ef763 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/float_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/float_wrapper.py @@ -26,6 +26,6 @@ class FloatWrapper(Model): 'field2': {'key': 'field2', 'type': 'float'}, } - def __init__(self, field1=None, field2=None, **kwargs): + def __init__(self, field1=None, field2=None): self.field1 = field1 self.field2 = field2 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/goblinshark.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/goblinshark.py index c9cf046ed0cb5..a119ee4d6e574 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/goblinshark.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/goblinshark.py @@ -48,7 +48,7 @@ class Goblinshark(Shark): 'jawsize': {'key': 'jawsize', 'type': 'int'}, } - def __init__(self, length, birthday, species=None, siblings=None, age=None, jawsize=None, **kwargs): - super(Goblinshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) + def __init__(self, length, birthday, species=None, siblings=None, age=None, jawsize=None): + super(Goblinshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday) self.jawsize = jawsize self.fishtype = 'goblin' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/int_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/int_wrapper.py index ad9a60209e698..92136de6442c0 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/int_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/int_wrapper.py @@ -26,6 +26,6 @@ class IntWrapper(Model): 'field2': {'key': 'field2', 'type': 'int'}, } - def __init__(self, field1=None, field2=None, **kwargs): + def __init__(self, field1=None, field2=None): self.field1 = field1 self.field2 = field2 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/long_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/long_wrapper.py index 350dff72efff5..70a8c78b56d3b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/long_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/long_wrapper.py @@ -26,6 +26,6 @@ class LongWrapper(Model): 'field2': {'key': 'field2', 'type': 'long'}, } - def __init__(self, field1=None, field2=None, **kwargs): + def __init__(self, field1=None, field2=None): self.field1 = field1 self.field2 = field2 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/pet.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/pet.py index f637af26154de..ae794dc5f6338 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/pet.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/pet.py @@ -26,6 +26,6 @@ class Pet(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, name=None, **kwargs): + def __init__(self, id=None, name=None): self.id = id self.name = name diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/readonly_obj.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/readonly_obj.py index 54f617ab191ec..f0db42cc1b3f9 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/readonly_obj.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/readonly_obj.py @@ -26,6 +26,6 @@ class ReadonlyObj(Model): 'size': {'key': 'size', 'type': 'int'}, } - def __init__(self, id=None, size=None, **kwargs): + def __init__(self, id=None, size=None): self.id = id self.size = size diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/salmon.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/salmon.py index 94073cb2b7e36..ca9ac00e67109 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/salmon.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/salmon.py @@ -44,8 +44,8 @@ class Salmon(Fish): 'iswild': {'key': 'iswild', 'type': 'bool'}, } - def __init__(self, length, species=None, siblings=None, location=None, iswild=None, **kwargs): - super(Salmon, self).__init__(species=species, length=length, siblings=siblings, **kwargs) + def __init__(self, length, species=None, siblings=None, location=None, iswild=None): + super(Salmon, self).__init__(species=species, length=length, siblings=siblings) self.location = location self.iswild = iswild self.fishtype = 'salmon' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/sawshark.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/sawshark.py index 9666b532506da..eb5f018fd759b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/sawshark.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/sawshark.py @@ -48,7 +48,7 @@ class Sawshark(Shark): 'picture': {'key': 'picture', 'type': 'bytearray'}, } - def __init__(self, length, birthday, species=None, siblings=None, age=None, picture=None, **kwargs): - super(Sawshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday, **kwargs) + def __init__(self, length, birthday, species=None, siblings=None, age=None, picture=None): + super(Sawshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday) self.picture = picture self.fishtype = 'sawshark' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/shark.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/shark.py index 51fe0956bf51d..18d4187ebede9 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/shark.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/shark.py @@ -49,8 +49,8 @@ class Shark(Fish): 'fishtype': {'sawshark': 'Sawshark', 'goblin': 'Goblinshark', 'cookiecuttershark': 'Cookiecuttershark'} } - def __init__(self, length, birthday, species=None, siblings=None, age=None, **kwargs): - super(Shark, self).__init__(species=species, length=length, siblings=siblings, **kwargs) + def __init__(self, length, birthday, species=None, siblings=None, age=None): + super(Shark, self).__init__(species=species, length=length, siblings=siblings) self.age = age self.birthday = birthday self.fishtype = 'shark' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/siamese.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/siamese.py index a52c0d69892b1..ad83ab4771cf1 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/siamese.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/siamese.py @@ -36,6 +36,6 @@ class Siamese(Cat): 'breed': {'key': 'breed', 'type': 'str'}, } - def __init__(self, id=None, name=None, color=None, hates=None, breed=None, **kwargs): - super(Siamese, self).__init__(id=id, name=name, color=color, hates=hates, **kwargs) + def __init__(self, id=None, name=None, color=None, hates=None, breed=None): + super(Siamese, self).__init__(id=id, name=name, color=color, hates=hates) self.breed = breed diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/string_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/string_wrapper.py index 19bb78f4673a5..a01f361cdba21 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/string_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/string_wrapper.py @@ -29,7 +29,7 @@ class StringWrapper(Model): 'null': {'key': 'null', 'type': 'str'}, } - def __init__(self, field=None, empty=None, null=None, **kwargs): + def __init__(self, field=None, empty=None, null=None): self.field = field self.empty = empty self.null = null diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/setup.py index c67f7c49a7562..65d0a41a65f59 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/setup.py index 09e6aa6e8c9ef..c70f0e8100516 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/setup.py index 420c600dff136..ac383e8eb0acb 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py index b323ed157ce25..143969182ad02 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/widget.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/widget.py index 3ac8dcf6034e4..3a3c86f698dd4 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/widget.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/models/widget.py @@ -26,6 +26,6 @@ class Widget(Model): 'string': {'key': 'string', 'type': 'str'}, } - def __init__(self, integer=None, string=None, **kwargs): + def __init__(self, integer=None, string=None): self.integer = integer self.string = string diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/setup.py index 6dcd5850b3d44..3326b76166d12 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/setup.py index 3340f8db5b9cd..88bb6938d4a09 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/setup.py index 918eb67dcd7c0..ff524cfed3430 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/setup.py index 03d887addbd35..f71daa3028819 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/setup.py index a85431ad534e1..c203877495320 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/setup.py index 2948a18b3e493..7495879ab1b3f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/setup.py index adcf15f154920..26c1dc8c835ef 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py index 570afdaa95129..5839338b5a2d2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/auto_rest_parameterized_host_test_client.py @@ -31,7 +31,9 @@ def __init__( self, host, filepath=None): if host is None: - raise ValueError('host must not be None.') + raise ValueError("Parameter 'host' must not be None.") + if not isinstance(host, str): + raise TypeError("Parameter 'host' must be str.") base_url = 'http://{accountName}{host}' super(AutoRestParameterizedHostTestClientConfiguration, self).__init__(base_url, filepath) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py index bb4a542940856..20758a3b0efba 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/__init__.py new file mode 100644 index 0000000000000..6711cf5b14df9 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/__init__.py @@ -0,0 +1,21 @@ +# 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 .auto_rest_parameterized_custom_host_test_client import AutoRestParameterizedCustomHostTestClient, AutoRestParameterizedCustomHostTestClientConfiguration +from .version import VERSION + +__all__ = [ + 'AutoRestParameterizedCustomHostTestClient', + 'AutoRestParameterizedCustomHostTestClientConfiguration' +] + +__version__ = VERSION + diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/auto_rest_parameterized_custom_host_test_client.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/auto_rest_parameterized_custom_host_test_client.py new file mode 100644 index 0000000000000..1e9140c3e5f70 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/auto_rest_parameterized_custom_host_test_client.py @@ -0,0 +1,69 @@ +# 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.service_client import ServiceClient +from msrest import Configuration, Serializer, Deserializer +from .version import VERSION +from .operations.paths import Paths +from . import models + + +class AutoRestParameterizedCustomHostTestClientConfiguration(Configuration): + """Configuration for AutoRestParameterizedCustomHostTestClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param subscription_id: The subscription id with value 'test12'. + :type subscription_id: str + :param dns_suffix: A string value that is used as a global part of the + parameterized host. Default value 'host'. + :type dns_suffix: str + :param str filepath: Existing config + """ + + def __init__( + self, subscription_id, dns_suffix, filepath=None): + + if subscription_id is None: + raise ValueError('subscription_id must not be None.') + if dns_suffix is None: + raise ValueError('dns_suffix must not be None.') + base_url = '{vault}{secret}{dnsSuffix}' + + super(AutoRestParameterizedCustomHostTestClientConfiguration, self).__init__(base_url, filepath) + + self.add_user_agent('autorestparameterizedcustomhosttestclient/{}'.format(VERSION)) + + self.subscription_id = subscription_id + self.dns_suffix = dns_suffix + + +class AutoRestParameterizedCustomHostTestClient(object): + """Test Infrastructure for AutoRest + + :param config: Configuration for client. + :type config: AutoRestParameterizedCustomHostTestClientConfiguration + + :ivar paths: Paths operations + :vartype paths: .operations.Paths + """ + + def __init__(self, config): + + self._client = ServiceClient(None, config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer() + self._deserialize = Deserializer(client_models) + + self.config = config + self.paths = Paths( + self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/credentials.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/credentials.py new file mode 100644 index 0000000000000..0d097b4f2a6cf --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/credentials.py @@ -0,0 +1,15 @@ +# 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.authentication import ( + BasicAuthentication, + BasicTokenAuthentication, + OAuthTokenAuthentication) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/exceptions.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/exceptions.py new file mode 100644 index 0000000000000..c3cc00226060c --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/exceptions.py @@ -0,0 +1,21 @@ +# 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.exceptions import ( + ClientException, + SerializationError, + DeserializationError, + TokenExpiredError, + ClientRequestError, + AuthenticationError, + HttpOperationError, + ValidationError, +) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/__init__.py new file mode 100644 index 0000000000000..fd6d517a47113 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/__init__.py @@ -0,0 +1,16 @@ +# 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 .error import Error, ErrorException + +__all__ = [ + 'Error', 'ErrorException', +] diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/error.py new file mode 100644 index 0000000000000..c2d19e377e004 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/models/error.py @@ -0,0 +1,44 @@ +# 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 +from msrest.exceptions import HttpOperationError + + +class Error(Model): + """Error + + :param status: + :type status: int + :param message: + :type message: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'int'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, status=None, message=None): + self.status = status + self.message = message + + +class ErrorException(HttpOperationError): + """Server responsed with exception of type: 'Error'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorException, self).__init__(deserialize, response, 'Error', *args) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/__init__.py new file mode 100644 index 0000000000000..fa4a82a28df55 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/__init__.py @@ -0,0 +1,16 @@ +# 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 .paths import Paths + +__all__ = [ + 'Paths', +] diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/paths.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/paths.py new file mode 100644 index 0000000000000..2c43f455f742d --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/paths.py @@ -0,0 +1,87 @@ +# 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.pipeline import ClientRawResponse + +from .. import models + + +class Paths(object): + """Paths operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def get_empty( + self, vault, secret, key_name, key_version="v1", custom_headers={}, raw=False, **operation_config): + """ + Get a 200 to test a valid base uri + + :param vault: The vault name, e.g. https://myvault + :type vault: str + :param secret: Secret value. + :type secret: str + :param key_name: The key name with value 'key1'. + :type key_name: str + :param key_version: The key version. Default value 'v1'. + :type key_version: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: None + :rtype: :class:`ClientRawResponse` + if raw=true + """ + # Construct URL + url = '/customuri/{subscriptionId}/{keyName}' + path_format_arguments = { + 'vault': self._serialize.url("vault", vault, 'str', skip_quote=True), + 'secret': self._serialize.url("secret", secret, 'str', skip_quote=True), + 'dnsSuffix': self._serialize.url("self.config.dns_suffix", self.config.dns_suffix, 'str', skip_quote=True), + 'keyName': self._serialize.url("key_name", key_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if key_version is not None: + query_parameters['keyVersion'] = self._serialize.query("key_version", key_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # 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]: + raise models.ErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/version.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/version.py new file mode 100644 index 0000000000000..a39916c162cec --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0" + diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py new file mode 100644 index 0000000000000..3521fb6abef92 --- /dev/null +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/setup.py @@ -0,0 +1,40 @@ +# 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. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "autorestparameterizedcustomhosttestclient" +VERSION = "1.0.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.2.0"] + +setup( + name=NAME, + version=VERSION, + description="AutoRestParameterizedCustomHostTestClient", + author_email="", + url="", + keywords=["Swagger", "AutoRestParameterizedCustomHostTestClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Test Infrastructure for AutoRest + """ +) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/setup.py index bf58eae79e6c9..2e773b93aad57 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/a.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/a.py index 291d1604b627f..f6baf6ea42b4c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/a.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/a.py @@ -24,7 +24,7 @@ class A(Model): 'status_code': {'key': 'statusCode', 'type': 'str'}, } - def __init__(self, status_code=None, **kwargs): + def __init__(self, status_code=None): self.status_code = status_code diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/b.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/b.py index 4b73a497c8406..0853087e7d476 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/b.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/b.py @@ -26,6 +26,6 @@ class B(A): 'text_status_code': {'key': 'textStatusCode', 'type': 'str'}, } - def __init__(self, status_code=None, text_status_code=None, **kwargs): - super(B, self).__init__(status_code=status_code, **kwargs) + def __init__(self, status_code=None, text_status_code=None): + super(B, self).__init__(status_code=status_code) self.text_status_code = text_status_code diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/c.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/c.py index ec12dffd7884a..2e23c31e92048 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/c.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/c.py @@ -23,5 +23,5 @@ class C(Model): 'http_code': {'key': 'httpCode', 'type': 'str'}, } - def __init__(self, http_code=None, **kwargs): + def __init__(self, http_code=None): self.http_code = http_code diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/d.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/d.py index 3e08e4489c52a..8b32eef124a99 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/d.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/d.py @@ -23,5 +23,5 @@ class D(Model): 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, } - def __init__(self, http_status_code=None, **kwargs): + def __init__(self, http_status_code=None): self.http_status_code = http_status_code diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/setup.py index 2db682d7ec3dc..e08efb221837d 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/base_product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/base_product.py index 55707c63063ed..ad8b2a34ebceb 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/base_product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/base_product.py @@ -33,6 +33,6 @@ class BaseProduct(Model): 'description': {'key': 'base_product_description', 'type': 'str'}, } - def __init__(self, product_id, description=None, **kwargs): + def __init__(self, product_id, description=None): self.product_id = product_id self.description = description diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/error.py index bb9d41eb9cbde..0ff39bf5de7f9 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/error.py @@ -31,7 +31,7 @@ class Error(Model): 'parent_error': {'key': 'parentError', 'type': 'Error'}, } - def __init__(self, status=None, message=None, parent_error=None, **kwargs): + def __init__(self, status=None, message=None, parent_error=None): self.status = status self.message = message self.parent_error = parent_error diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py index 8158dc7e601df..ef30dd1f2d039 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py @@ -38,7 +38,7 @@ class FlattenParameterGroup(Model): 'max_product_display_name': {'required': True}, } - def __init__(self, name, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None, **kwargs): + def __init__(self, name, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None): self.name = name self.product_id = product_id self.description = description 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 458eef6da4c3d..99e49b9aa384f 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 @@ -49,8 +49,8 @@ class FlattenedProduct(Resource): 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, pname=None, flattened_product_type=None, provisioning_state_values=None, provisioning_state=None, **kwargs): - super(FlattenedProduct, self).__init__(id=id, type=type, tags=tags, location=location, name=name, **kwargs) + def __init__(self, id=None, type=None, tags=None, location=None, name=None, pname=None, flattened_product_type=None, provisioning_state_values=None, provisioning_state=None): + super(FlattenedProduct, self).__init__(id=id, type=type, tags=tags, location=location, name=name) self.pname = pname self.flattened_product_type = flattened_product_type self.provisioning_state_values = provisioning_state_values diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/generic_url.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/generic_url.py index 9bfb97699cb61..44d207c724ad2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/generic_url.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/generic_url.py @@ -24,5 +24,5 @@ class GenericUrl(Model): 'generic_value': {'key': 'generic_value', 'type': 'str'}, } - def __init__(self, generic_value=None, **kwargs): + def __init__(self, generic_value=None): self.generic_value = generic_value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource.py index c2e81e8035ee3..ccc46d79f60ce 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource.py @@ -35,7 +35,7 @@ class Resource(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, type=None, tags=None, location=None, name=None, **kwargs): + def __init__(self, id=None, type=None, tags=None, location=None, name=None): self.id = id self.type = type self.tags = tags diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource_collection.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource_collection.py index e84cbdeba5dea..b4c53e9e238ba 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource_collection.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/resource_collection.py @@ -31,7 +31,7 @@ class ResourceCollection(Model): 'dictionaryofresources': {'key': 'dictionaryofresources', 'type': '{FlattenedProduct}'}, } - def __init__(self, productresource=None, arrayofresources=None, dictionaryofresources=None, **kwargs): + def __init__(self, productresource=None, arrayofresources=None, dictionaryofresources=None): self.productresource = productresource self.arrayofresources = arrayofresources self.dictionaryofresources = dictionaryofresources diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/simple_product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/simple_product.py index 38d5be1405c1f..1be642054ecac 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/simple_product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/simple_product.py @@ -36,7 +36,7 @@ class SimpleProduct(BaseProduct): _validation = { 'product_id': {'required': True}, 'max_product_display_name': {'required': True}, - 'capacity': {'required': True}, + 'capacity': {'required': True, 'constant': True}, } _attribute_map = { @@ -48,8 +48,8 @@ class SimpleProduct(BaseProduct): 'odatavalue': {'key': 'details.max_product_image.@odata\\.value', 'type': 'str'}, } - def __init__(self, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None, **kwargs): - super(SimpleProduct, self).__init__(product_id=product_id, description=description, **kwargs) + def __init__(self, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None): + super(SimpleProduct, self).__init__(product_id=product_id, description=description) self.max_product_display_name = max_product_display_name self.capacity = "Large" self.generic_value = generic_value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/setup.py index 4eebe2a59088e..326c330b62a5b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/models/availability_set_update_parameters.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/models/availability_set_update_parameters.py index 7c14ba67a9fd0..eb0b7aa4d4e00 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/models/availability_set_update_parameters.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/models/availability_set_update_parameters.py @@ -27,5 +27,5 @@ class AvailabilitySetUpdateParameters(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, tags, **kwargs): + def __init__(self, tags): self.tags = tags diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/setup.py index 81ec092249336..1e6900d3ef817 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/setup.py index c1ba503f44a53..ff3a17c58c7ff 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/auto_rest_required_optional_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/auto_rest_required_optional_test_service.py index d9a36a8ffd5b0..7dcce131d92ad 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/auto_rest_required_optional_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/auto_rest_required_optional_test_service.py @@ -36,9 +36,13 @@ def __init__( self, required_global_path, required_global_query, optional_global_query=None, base_url=None, filepath=None): if required_global_path is None: - raise ValueError('required_global_path must not be None.') + raise ValueError("Parameter 'required_global_path' must not be None.") + if not isinstance(required_global_path, str): + raise TypeError("Parameter 'required_global_path' must be str.") if required_global_query is None: - raise ValueError('required_global_query must not be None.') + raise ValueError("Parameter 'required_global_query' must not be None.") + if not isinstance(required_global_query, str): + raise TypeError("Parameter 'required_global_query' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_optional_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_optional_wrapper.py index b5c3efad06a28..cb71ed5d5debe 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_optional_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_optional_wrapper.py @@ -23,5 +23,5 @@ class ArrayOptionalWrapper(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, value=None, **kwargs): + def __init__(self, value=None): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_wrapper.py index 7eb7270bfd325..43685d1c6dba2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/array_wrapper.py @@ -27,5 +27,5 @@ class ArrayWrapper(Model): 'value': {'key': 'value', 'type': '[str]'}, } - def __init__(self, value, **kwargs): + def __init__(self, value): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_optional_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_optional_wrapper.py index 269a6f0c146a3..4d0d010de7de7 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_optional_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_optional_wrapper.py @@ -24,5 +24,5 @@ class ClassOptionalWrapper(Model): 'value': {'key': 'value', 'type': 'Product'}, } - def __init__(self, value=None, **kwargs): + def __init__(self, value=None): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_wrapper.py index 9e9278497aaf4..ff139aaf09fd4 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/class_wrapper.py @@ -28,5 +28,5 @@ class ClassWrapper(Model): 'value': {'key': 'value', 'type': 'Product'}, } - def __init__(self, value, **kwargs): + def __init__(self, value): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_optional_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_optional_wrapper.py index ec49c66263db1..366aa950c993d 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_optional_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_optional_wrapper.py @@ -23,5 +23,5 @@ class IntOptionalWrapper(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, value=None, **kwargs): + def __init__(self, value=None): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_wrapper.py index 558b905ae14b7..9d20dbc5fba7a 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/int_wrapper.py @@ -27,5 +27,5 @@ class IntWrapper(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, value, **kwargs): + def __init__(self, value): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/product.py index 438c0c95e8f11..68be843067783 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/product.py @@ -30,6 +30,6 @@ class Product(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id, name=None, **kwargs): + def __init__(self, id, name=None): self.id = id self.name = name diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_optional_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_optional_wrapper.py index 70f024163a822..b7484c342146e 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_optional_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_optional_wrapper.py @@ -23,5 +23,5 @@ class StringOptionalWrapper(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, value=None, **kwargs): + def __init__(self, value=None): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_wrapper.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_wrapper.py index 8494e03473016..659da492dd4f5 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_wrapper.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/models/string_wrapper.py @@ -27,5 +27,5 @@ class StringWrapper(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, value, **kwargs): + def __init__(self, value): self.value = value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/setup.py index aa49668c0f66d..14f66afcfb516 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/auto_rest_url_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/auto_rest_url_test_service.py index 31c1880929875..34efde192fd6b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/auto_rest_url_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/auto_rest_url_test_service.py @@ -36,7 +36,11 @@ def __init__( self, global_string_path, global_string_query=None, base_url=None, filepath=None): if global_string_path is None: - raise ValueError('global_string_path must not be None.') + raise ValueError("Parameter 'global_string_path' must not be None.") + if not isinstance(global_string_path, str): + raise TypeError("Parameter 'global_string_path' must be str.") + if global_string_query is not None and not isinstance(global_string_query, str): + raise TypeError("Optional parameter 'global_string_query' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/models/error.py index b8957d8dfa0cc..c2d19e377e004 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/models/error.py @@ -27,7 +27,7 @@ class Error(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, status=None, message=None, **kwargs): + def __init__(self, status=None, message=None): self.status = status self.message = message diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/paths.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/paths.py index 46bface0d9375..97cd8878c0e6a 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/paths.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/paths.py @@ -1089,7 +1089,7 @@ def array_csv_in_path( if raw=true """ # Construct URL - url = '/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath:commaSeparated}' + url = '/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}' path_format_arguments = { 'arrayPath': self._serialize.url("array_path", array_path, '[str]', div=',') } diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/setup.py index 5db4f0ba4406a..5ecd97fb73461 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/auto_rest_validation_test.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/auto_rest_validation_test.py index 7fd4093d00b6e..f9a6b88ede469 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/auto_rest_validation_test.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/auto_rest_validation_test.py @@ -34,9 +34,13 @@ def __init__( self, subscription_id, api_version, base_url=None, filepath=None): if subscription_id is None: - raise ValueError('subscription_id must not be None.') + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") if api_version is None: - raise ValueError('api_version must not be None.') + raise ValueError("Parameter 'api_version' must not be None.") + if not isinstance(api_version, str): + raise TypeError("Parameter 'api_version' must be str.") if not base_url: base_url = 'http://localhost' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/child_product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/child_product.py index 9c02450e6e110..e7270ddf47641 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/child_product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/child_product.py @@ -23,7 +23,7 @@ class ChildProduct(Model): """ _validation = { - 'const_property': {'required': True}, + 'const_property': {'required': True, 'constant': True}, } _attribute_map = { @@ -31,6 +31,6 @@ class ChildProduct(Model): 'count': {'key': 'count', 'type': 'int'}, } - def __init__(self, count=None, **kwargs): + def __init__(self, count=None): self.const_property = "constant" self.count = count diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/constant_product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/constant_product.py index 98f60fd2eab82..14f416cef6f00 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/constant_product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/constant_product.py @@ -23,8 +23,8 @@ class ConstantProduct(Model): """ _validation = { - 'const_property': {'required': True}, - 'const_property2': {'required': True}, + 'const_property': {'required': True, 'constant': True}, + 'const_property2': {'required': True, 'constant': True}, } _attribute_map = { @@ -32,6 +32,6 @@ class ConstantProduct(Model): 'const_property2': {'key': 'constProperty2', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__(self): self.const_property = "constant" self.const_property2 = "constant2" diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/error.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/error.py index 7284a2e86309f..3cd8f0d632c08 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/error.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/error.py @@ -30,7 +30,7 @@ class Error(Model): 'fields': {'key': 'fields', 'type': 'str'}, } - def __init__(self, code=None, message=None, fields=None, **kwargs): + def __init__(self, code=None, message=None, fields=None): self.code = code self.message = message self.fields = fields diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/product.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/product.py index 0447d1ff7f400..c9577fa07f23d 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/product.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/models/product.py @@ -43,9 +43,9 @@ class Product(Model): 'capacity': {'maximum_ex': 100, 'minimum_ex': 0}, 'image': {'pattern': 'http://\w+'}, 'child': {'required': True}, - 'const_child': {'required': True}, - 'const_int': {'required': True}, - 'const_string': {'required': True}, + 'const_child': {'required': True, 'constant': True}, + 'const_int': {'required': True, 'constant': True}, + 'const_string': {'required': True, 'constant': True}, } _attribute_map = { @@ -59,7 +59,7 @@ class Product(Model): 'const_string_as_enum': {'key': 'constStringAsEnum', 'type': 'EnumConst'}, } - def __init__(self, child, display_names=None, capacity=None, image=None, const_string_as_enum=None, **kwargs): + def __init__(self, child, display_names=None, capacity=None, image=None, const_string_as_enum=None): self.display_names = display_names self.capacity = capacity self.image = image diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/setup.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/setup.py index 22a1da7feac0a..3d693bfbb149f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/setup.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/AutoRest/Generators/Python/Python.Tests/Python.Tests.pyproj b/AutoRest/Generators/Python/Python.Tests/Python.Tests.pyproj index 551692fe3e198..b6cfb6ea96c3e 100644 --- a/AutoRest/Generators/Python/Python.Tests/Python.Tests.pyproj +++ b/AutoRest/Generators/Python/Python.Tests/Python.Tests.pyproj @@ -125,6 +125,10 @@ + + + + diff --git a/AutoRest/Generators/Python/Python/PythonCodeGenerator.cs b/AutoRest/Generators/Python/Python/PythonCodeGenerator.cs index ff332c771c70e..d987055d49f6f 100644 --- a/AutoRest/Generators/Python/Python/PythonCodeGenerator.cs +++ b/AutoRest/Generators/Python/Python/PythonCodeGenerator.cs @@ -16,7 +16,7 @@ namespace Microsoft.Rest.Generator.Python { public class PythonCodeGenerator : CodeGenerator { - private const string ClientRuntimePackage = "msrest version 0.1.0"; + private const string ClientRuntimePackage = "msrest version 0.2.0"; public PythonCodeGenerator(Settings settings) : base(settings) { diff --git a/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs index 5c47e7be1f83c..0555d5cd4434e 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Linq; using System.Net; +using System.Text.RegularExpressions; using Microsoft.Rest.Generator.ClientModel; using Microsoft.Rest.Generator.Python.TemplateModels; using Microsoft.Rest.Generator.Utilities; @@ -31,6 +32,12 @@ public MethodTemplateModel(Method source, ServiceClient serviceClient) OperationName = serviceClient.Name; } AddCustomHeader = true; + string formatter; + foreach (Match m in Regex.Matches(Url, @"\{[\w]+:[\w]+\}")) + { + formatter = m.Value.Split(':').First() + '}'; + Url = Url.Replace(m.Value, formatter); + } } public bool AddCustomHeader { get; private set; } diff --git a/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs index c63acff125dfc..dbd8fd040ff5f 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs @@ -100,6 +100,10 @@ public IList Validators { validation.Add("'required': True"); } + if (parameter.IsConstant) + { + validation.Add("'constant': True"); + } if (parameter.Constraints.Any()) { validation.AddRange(BuildValidationParameters(parameter.Constraints)); diff --git a/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs index 3e9d595d83f47..60629ea26ca28 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs @@ -105,7 +105,10 @@ public virtual string RequiredConstructorParameters } } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ValueError"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "ValueError"), + System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "TypeError"), + System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "str"), + System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Microsoft.Rest.Generator.Utilities.IndentedStringBuilder.AppendLine(System.String)")] public virtual string ValidateRequiredParameters { get @@ -118,9 +121,31 @@ public virtual string ValidateRequiredParameters builder. AppendFormat("if {0} is None:", property.Name.ToPythonCase()).AppendLine(). Indent(). - AppendLine(string.Format(CultureInfo.InvariantCulture, "raise ValueError('{0} must not be None.')", property.Name.ToPythonCase())). + AppendLine(string.Format(CultureInfo.InvariantCulture, "raise ValueError(\"Parameter '{0}' must not be None.\")", property.Name.ToPythonCase())). Outdent(); + if (property.Type.IsPrimaryType(KnownPrimaryType.String)) + { + builder. + AppendFormat("if not isinstance({0}, str):", property.Name.ToPythonCase()).AppendLine(). + Indent(). + AppendLine(string.Format(CultureInfo.InvariantCulture, "raise TypeError(\"Parameter '{0}' must be str.\")", property.Name.ToPythonCase())). + Outdent(); + } } + else + { + if (property.Type.IsPrimaryType(KnownPrimaryType.String)) + { + builder. + AppendFormat("if {0} is not None and not isinstance({0}, str):", property.Name.ToPythonCase()).AppendLine(). + Indent(). + AppendLine(string.Format(CultureInfo.InvariantCulture, "raise TypeError(\"Optional parameter '{0}' must be str.\")", property.Name.ToPythonCase())). + Outdent(); + } + + } + + } return builder.ToString(); } @@ -138,7 +163,7 @@ public virtual string SetupRequires { get { - return "\"msrest>=0.1.0\""; + return "\"msrest>=0.2.0\""; } } diff --git a/AutoRest/Generators/Python/Python/Templates/ModelTemplate.cshtml b/AutoRest/Generators/Python/Python/Templates/ModelTemplate.cshtml index d035a46155cf1..40ee94f75cb4b 100644 --- a/AutoRest/Generators/Python/Python/Templates/ModelTemplate.cshtml +++ b/AutoRest/Generators/Python/Python/Templates/ModelTemplate.cshtml @@ -90,10 +90,10 @@ else } @EmptyLine - def __init__(self@(Model.MethodParameterDeclaration()), **kwargs): + def __init__(self@(Model.MethodParameterDeclaration())): @if (Model.HasParent) { - @:super(@(Model.Name), self).__init__(@(Model.SuperParameterDeclaration()), **kwargs) + @:super(@(Model.Name), self).__init__(@(Model.SuperParameterDeclaration())) } @{ var propertyList = new List(Model.Properties); diff --git a/AutoRest/Modelers/Swagger/CollectionFormatBuilder.cs b/AutoRest/Modelers/Swagger/CollectionFormatBuilder.cs index edfba8a2c1340..f9ee08f3c57f6 100644 --- a/AutoRest/Modelers/Swagger/CollectionFormatBuilder.cs +++ b/AutoRest/Modelers/Swagger/CollectionFormatBuilder.cs @@ -80,7 +80,7 @@ private static void AddCollectionFormat(SwaggerParameter swaggerParameter, Strin break; case CollectionFormat.Multi: - // TODO multi is not supported yet: http://vstfrd:8080/Azure/RD/_workitems/edit/3172867 + // TODO multi is not supported yet: https://github.com/Azure/autorest/issues/717 throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, Resources.MultiCollectionFormatNotSupported, swaggerParameter.Name)); diff --git a/AutoRest/TestServer/server/app.js b/AutoRest/TestServer/server/app.js index f0da0d60682c8..8bb3b105ba765 100644 --- a/AutoRest/TestServer/server/app.js +++ b/AutoRest/TestServer/server/app.js @@ -428,6 +428,8 @@ var coverage = { "ConstantsInPath": 0, "ConstantsInBody": 0, "CustomBaseUri": 0, + //Once all the languages implement this test, the scenario counter should be reset to zero. It is currently implemented in C# and node.js + "CustomBaseUriMoreOptions": 1, 'getModelFlattenArray': 0, 'putModelFlattenArray': 0, 'getModelFlattenDictionary': 0, diff --git a/AutoRest/TestServer/server/routes/customUri.js b/AutoRest/TestServer/server/routes/customUri.js index 2eee79cadfc33..85d074cdeceb2 100644 --- a/AutoRest/TestServer/server/routes/customUri.js +++ b/AutoRest/TestServer/server/routes/customUri.js @@ -9,6 +9,17 @@ var specials = function (coverage) { coverage['CustomBaseUri']++; res.status(200).end(); }); + + router.get('/:subscriptionId/:keyName', function (req, res, next) { + if (req.params.subscriptionId === 'test12' && req.params.keyName === 'key1' + && Object.keys(req.query).length == 1 && req.query.keyVersion === 'v1') { + coverage['CustomBaseUriMoreOptions']++; + res.status(200).end(); + } else { + utils.send400(res, next, 'Either one of the path parameters (subscriptionId=test12, keyName=key1) or query parameter (keyVersion=v1) did not match. ' + + 'Received parameters are: subscriptionId ' + subscriptionId + ', keyName ' + keyName + ', keyVersion ' + keyVersion); + } + }); } specials.prototype.router = router; diff --git a/AutoRest/TestServer/swagger/custom-baseUrl-more-options.json b/AutoRest/TestServer/swagger/custom-baseUrl-more-options.json new file mode 100644 index 0000000000000..75ef7453976ee --- /dev/null +++ b/AutoRest/TestServer/swagger/custom-baseUrl-more-options.json @@ -0,0 +1,108 @@ +{ + "swagger": "2.0", + "info": { + "title": "AutoRest Parameterized Custom Host Test Client", + "description": "Test Infrastructure for AutoRest", + "version": "1.0.0" + }, + "x-ms-parameterized-host": { + "hostTemplate": "{vault}{secret}{dnsSuffix}", + "useSchemePrefix": false, + "parameters": [ + { + "name": "vault", + "description": "The vault name, e.g. https://myvault", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true + }, + { + "name": "secret", + "description": "Secret value.", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true + }, + { + "$ref": "#/parameters/dnsSuffix" + } + ] + }, + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/customuri/{subscriptionId}/{keyName}": { + "get": { + "operationId": "paths_getEmpty", + "description": "Get a 200 to test a valid base uri", + "tags": [ + "Path Operations" + ], + "parameters": [ + { + "name": "keyName", + "in": "path", + "required": true, + "type": "string", + "description": "The key name with value 'key1'." + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "name": "keyVersion", + "in": "query", + "required": false, + "type": "string", + "default": "v1", + "description": "The key version. Default value 'v1'." + } + ], + "responses": { + "200": { + "description": "Successfully received a 200 response" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "The subscription id with value 'test12'." + }, + "dnsSuffix": { + "name": "dnsSuffix", + "description": "A string value that is used as a global part of the parameterized host. Default value 'host'.", + "type": "string", + "required": false, + "default": "host", + "in": "path", + "x-ms-skip-url-encoding": true + } + }, + "definitions": { + "Error": { + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } +} diff --git a/AutoRest/TestServer/swagger/custom-baseUrl.json b/AutoRest/TestServer/swagger/custom-baseUrl.json index 5ca07d1627a06..aaa0309f4b94a 100644 --- a/AutoRest/TestServer/swagger/custom-baseUrl.json +++ b/AutoRest/TestServer/swagger/custom-baseUrl.json @@ -8,6 +8,7 @@ "host": "badhost", "x-ms-parameterized-host": { "hostTemplate": "{accountName}{host}", + "positionInOperation": "last", "parameters": [ { "name": "accountName", diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs index 0d8505210fd5e..422f074bd3028 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs @@ -122,6 +122,38 @@ await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, return pollingState.AzureOperationResponse; } + /// + /// Gets operation result for PUT and PATCH operations. + /// + /// IAzureClient + /// Response from the begin operation + /// Headers that will be added to request + /// Cancellation token + /// Operation response + public static async Task GetPutOrPatchOperationResultAsync( + this IAzureClient client, + AzureOperationResponse response, + Dictionary> customHeaders, + CancellationToken cancellationToken) + { + var newResponse = new AzureOperationResponse + { + Request = response.Request, + Response = response.Response, + RequestId = response.RequestId + }; + + var azureOperationResponse = await client.GetPutOrPatchOperationResultAsync( + newResponse, customHeaders, cancellationToken); + + return new AzureOperationResponse + { + Request = azureOperationResponse.Request, + Response = azureOperationResponse.Response, + RequestId = azureOperationResponse.RequestId + }; + } + /// /// Gets operation result for DELETE and POST operations. /// diff --git a/ClientRuntimes/Java/client-runtime/build.gradle b/ClientRuntimes/Java/client-runtime/build.gradle index 47cbaf08c6397..b734d33608eaf 100644 --- a/ClientRuntimes/Java/client-runtime/build.gradle +++ b/ClientRuntimes/Java/client-runtime/build.gradle @@ -25,7 +25,7 @@ dependencies { compile 'com.google.guava:guava:18.0' compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.okhttp3:okhttp:3.2.0' - compile ('com.squareup.okio:okio:1.7.0-SNAPSHOT') { changing = true } + compile 'com.squareup.okio:okio:1.7.0' compile 'com.squareup.okhttp3:logging-interceptor:3.1.1' compile 'com.squareup.okhttp3:okhttp-urlconnection:3.1.1' compile 'com.squareup.retrofit2:converter-jackson:2.0.0-beta4' diff --git a/ClientRuntimes/Python/msrest/msrest/http_logger.py b/ClientRuntimes/Python/msrest/msrest/http_logger.py index b19405528cf96..5159a996a6e8f 100644 --- a/ClientRuntimes/Python/msrest/msrest/http_logger.py +++ b/ClientRuntimes/Python/msrest/msrest/http_logger.py @@ -81,8 +81,8 @@ def log_response(adapter, request, response, *args, **kwargs): _LOGGER.debug("Body contains binary data.") elif result.headers.get("content-type", "").startswith("image"): _LOGGER.debug("Body contains image data.") - # elif result.headers.get("transfer-encoding") == 'chunked': - # LOGGER.debug("Body contains chunked data.") + elif result.headers.get("transfer-encoding") == 'chunked': + _LOGGER.debug("Body contains chunked data.") else: _LOGGER.debug(str(result.content)) return result diff --git a/ClientRuntimes/Python/msrest/msrest/serialization.py b/ClientRuntimes/Python/msrest/msrest/serialization.py index 18254317e58e2..25aff136d1538 100644 --- a/ClientRuntimes/Python/msrest/msrest/serialization.py +++ b/ClientRuntimes/Python/msrest/msrest/serialization.py @@ -406,7 +406,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialized.append(None) if div: - return div.join(serialized) + serialized = ['' if s is None else s for s in serialized] + serialized = div.join(serialized) return serialized def serialize_dict(self, attr, dict_type, **kwargs): @@ -686,21 +687,33 @@ def _instantiate_model(self, response, attrs): :param response: The response model class. :param d_attrs: The deserialized response attributes. """ - subtype = response._get_subtype_map() - try: - kwargs = {k: v for k, v in attrs.items() if k not in subtype} - return response(**kwargs) - except TypeError: - pass - - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to instantiate or populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + if callable(response): + subtype = response._get_subtype_map() + try: + consts = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in consts} + response_obj = response(**kwargs) + + # We have to do this until we resolve the issue of complex + # constant attributes not being auto-instantiated. + for attr in consts: + setattr(response_obj, attr, attrs.get(attr)) + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) def deserialize_data(self, data, data_type): """Process data for deserialization according to data type. diff --git a/ClientRuntimes/Python/msrest/msrest/service_client.py b/ClientRuntimes/Python/msrest/msrest/service_client.py index 523c6648582f1..a204089838ddc 100644 --- a/ClientRuntimes/Python/msrest/msrest/service_client.py +++ b/ClientRuntimes/Python/msrest/msrest/service_client.py @@ -146,7 +146,7 @@ def send_formdata(self, request, headers={}, content={}, **config): :param ClientRequest request: The request object to be sent. :param dict headers: Any headers to add to the request. :param dict content: Dictionary of the fields of the formdata. - :param config: Any specific config overrides + :param config: Any specific config overrides. """ file_data = {f: self._format_data(d) for f, d in content.items()} try: @@ -163,6 +163,7 @@ def send(self, request, headers=None, content=None, **config): :param content: Any body data to add to the request. :param config: Any specific config overrides """ + response = None session = self.creds.signed_session() kwargs = self._configure_session(session, **config) @@ -204,7 +205,8 @@ def send(self, request, headers=None, content=None, **config): msg = "Error occurred in request." raise_with_traceback(ClientRequestError, msg, err) finally: - session.close() + if not response or response._content_consumed: + session.close() def stream_download(self, data, callback): """Generator for streaming request body data. @@ -229,6 +231,7 @@ def stream_download(self, data, callback): callback(chunk, response=data) yield chunk data.close() + self._adapter.close() def stream_upload(self, data, callback): """Generator for streaming request body data. diff --git a/ClientRuntimes/Python/msrest/test/unittest_runtime.py b/ClientRuntimes/Python/msrest/test/unittest_runtime.py index 7bb798d5af6d4..fbdad6791f772 100644 --- a/ClientRuntimes/Python/msrest/test/unittest_runtime.py +++ b/ClientRuntimes/Python/msrest/test/unittest_runtime.py @@ -101,7 +101,7 @@ def hook(aptr, req, *args, **kwargs): @mock.patch.object(requests, 'Session') def test_request_fail(self, mock_requests): - mock_requests.return_value.request.return_value = "test" + mock_requests.return_value.request.return_value = mock.Mock(_content_consumed=True) cfg = Configuration("https://my_service.com") creds = Authentication() @@ -113,7 +113,7 @@ def test_request_fail(self, mock_requests): check = httpretty.last_request() - self.assertEqual(response, "test") + self.assertTrue(response._content_consumed) mock_requests.return_value.request.side_effect = requests.RequestException with self.assertRaises(ClientRequestError): @@ -127,6 +127,8 @@ def test_request_proxy(self): def hook(adptr, request, *args, **kwargs): self.assertEqual(kwargs.get('proxies'), {"http://my_service.com":'http://localhost:57979'}) + kwargs['result']._content_consumed = True + kwargs['result'].status_code = 200 return kwargs['result'] client = ServiceClient(creds, cfg) @@ -139,6 +141,8 @@ def hook(adptr, request, *args, **kwargs): def hook2(adptr, request, *args, **kwargs): self.assertEqual(kwargs.get('proxies')['https'], "http://localhost:1987") + kwargs['result']._content_consumed = True + kwargs['result'].status_code = 200 return kwargs['result'] cfg = Configuration("http://my_service.com") diff --git a/ClientRuntimes/Python/msrestazure/doc/conf.py b/ClientRuntimes/Python/msrestazure/doc/conf.py index 0c188afe88a4c..9a76b3204d5c2 100644 --- a/ClientRuntimes/Python/msrestazure/doc/conf.py +++ b/ClientRuntimes/Python/msrestazure/doc/conf.py @@ -58,9 +58,9 @@ # built documents. # # The short X.Y version. -version = '0.2.0' +version = '0.2.1' # The full version, including alpha/beta/rc tags. -release = '0.2.0' +release = '0.2.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/ClientRuntimes/Python/msrestazure/msrestazure/version.py b/ClientRuntimes/Python/msrestazure/msrestazure/version.py index afe6b750dc35e..23c80b2514da3 100644 --- a/ClientRuntimes/Python/msrestazure/msrestazure/version.py +++ b/ClientRuntimes/Python/msrestazure/msrestazure/version.py @@ -24,4 +24,4 @@ # # -------------------------------------------------------------------------- -msrestazure_version = "0.2.0" +msrestazure_version = "0.2.1" diff --git a/ClientRuntimes/Python/msrestazure/readme.rst b/ClientRuntimes/Python/msrestazure/readme.rst index 6410f9f335943..18a49a8035f2b 100644 --- a/ClientRuntimes/Python/msrestazure/readme.rst +++ b/ClientRuntimes/Python/msrestazure/readme.rst @@ -15,6 +15,14 @@ To install: Release History --------------- +2016-03-31 Version 0.2.1 +++++++++++++++++++++++++ + +**Bugfixes** + +- Fix AzurePollerOperation if Swagger defines provisioning status as enum type (https://github.com/Azure/autorest/pull/892) + + 2016-03-25 Version 0.2.0 ++++++++++++++++++++++++ diff --git a/ClientRuntimes/Python/msrestazure/setup.py b/ClientRuntimes/Python/msrestazure/setup.py index 170ea10a30aa9..d25ce47f33493 100644 --- a/ClientRuntimes/Python/msrestazure/setup.py +++ b/ClientRuntimes/Python/msrestazure/setup.py @@ -28,7 +28,7 @@ setup( name='msrestazure', - version='0.2.0', + version='0.2.1', author='Microsoft Corporation', packages=['msrestazure'], url=('https://github.com/xingwu1/autorest/tree/python/' diff --git a/Documentation/swagger-extensions.md b/Documentation/swagger-extensions.md index cb3bed17ab585..1fbf0efe46d71 100644 --- a/Documentation/swagger-extensions.md +++ b/Documentation/swagger-extensions.md @@ -389,13 +389,19 @@ When used, replaces the standard Swagger "host" attribute with a host that conta Field Name | Type | Description ---|:---:|--- hostTemplate | `string` | **Required**. Specifies the parameterized template for the host. -parameters | [Array of Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject) | The list of parameters that are used within the hostTemplate. This can include both reference parameters as well as explicit parameters. Note that "in" is **required** and **must be** set to "path" +useSchemePrefix | `boolean` | **Optional, Default: true**. Specifes whether to prepend the default scheme a.k.a protocol to the base uri of client. +positionInOperation | `string` | **Optional, Default: first**. Specifies whether the list of parameters will appear in the beginning or in the end, in the method signature for every operation. The order within the parameters provided in the below mentioned array will be preserved. Either the array of parameters will be prepended or appended, based on the value provided over here. Valid values are **"first", "last"**. Every method/operation in any programming language has parameters categorized into two buckets **"required"** and **"optional"**. It is natural for optional paramaters to appear in the end in a method signature. **This aspect will be preserved, while prepending(first) or appending(last) hostTemplate parameters .** +parameters | [Array of Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject) | The list of parameters that are used within the hostTemplate. This can include both reference parameters as well as explicit parameters. Note that "in" is **required** and **must be** set to **"path"**. The reference parameters will be treated as **global parameters** and will end up as property of the client. **Example**: -Using both explicit and reference parameters +- Using both explicit and reference parameters. + - Since "useSchemePrefix" is not specified, it's default value true will be applied. The user is expected to provide only the value of accountName. The generated code will fit it as a part of the url. + - Since "positionInOperation" with value "last" is specified, "accountName" will be the last required parameter in every method. "adlaJobDnsSuffixInPath" will be a property on the client as it is defined in the global parameters section and is referenced here. + ```js "x-ms-parameterized-host": { "hostTemplate": "{accountName}.{adlaJobDnsSuffix}", + "positionInOperation": "last", "parameters": [ { "name": "accountName", @@ -421,10 +427,13 @@ Using both explicit and reference parameters "description": "Gets the DNS suffix used as the base for all Azure Data Lake Analytics Job service requests." } ``` -Using only explicit parameters +- Using explicit parameters and specifying the positionInOperation and schemePrefix. + - This means that accountName will be the first required parameter in all the methods and the user is expected to provide a url (protocol + accountName), since "useSchemePrfix" is set to false. ```js "x-ms-parameterized-host": { "hostTemplate": "{accountName}.mystaticsuffix.com", + "useSchemePrefix": false, + "positionInOperation": "first", "parameters": [ { "name": "accountName", diff --git a/Samples/azure-storage/Azure.Python/setup.py b/Samples/azure-storage/Azure.Python/setup.py index f3539db2972f1..b9fe5db7a8f35 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.1.0", "msrestazure>=0.1.0"] +REQUIRES = ["msrest>=0.2.0", "msrestazure>=0.2.1"] 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 0bbc5f5c291e2..1c7ee5c86a0b9 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 @@ -28,7 +28,7 @@ class CheckNameAvailabilityResult(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, name_available=None, reason=None, message=None, **kwargs): + def __init__(self, name_available=None, reason=None, message=None): self.name_available = name_available self.reason = reason self.message = message diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/custom_domain.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/custom_domain.py index ee95d5f7d6163..77a0857f912e8 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/custom_domain.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/custom_domain.py @@ -27,6 +27,6 @@ class CustomDomain(Model): 'use_sub_domain': {'key': 'useSubDomain', 'type': 'bool'}, } - def __init__(self, name, use_sub_domain=None, **kwargs): + def __init__(self, name, use_sub_domain=None): self.name = name self.use_sub_domain = use_sub_domain diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/endpoints.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/endpoints.py index de3d2386cd0a1..155622f51543c 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/endpoints.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/endpoints.py @@ -27,7 +27,7 @@ class Endpoints(Model): 'file': {'key': 'file', 'type': 'str'}, } - def __init__(self, blob=None, queue=None, table=None, file=None, **kwargs): + def __init__(self, blob=None, queue=None, table=None, file=None): self.blob = blob self.queue = queue self.table = table diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/resource.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/resource.py index 0bcb8add022c5..e784f717664d9 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/resource.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/resource.py @@ -28,7 +28,7 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, id=None, name=None, type=None, location=None, tags=None, **kwargs): + def __init__(self, id=None, name=None, type=None, location=None, tags=None): self.id = id self.name = name self.type = type diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account.py index 3949fa133fb15..274af1b58793d 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account.py @@ -33,6 +33,6 @@ class StorageAccount(Resource): 'properties': {'key': 'properties', 'type': 'StorageAccountProperties'}, } - def __init__(self, id=None, name=None, type=None, location=None, tags=None, properties=None, **kwargs): - super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags, **kwargs) + def __init__(self, id=None, name=None, type=None, location=None, tags=None, properties=None): + super(StorageAccount, self).__init__(id=id, name=name, type=type, location=location, tags=tags) self.properties = properties diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_check_name_availability_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_check_name_availability_parameters.py index 2ee4a450e04a8..bca58a1d79bab 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_check_name_availability_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_check_name_availability_parameters.py @@ -23,6 +23,6 @@ class StorageAccountCheckNameAvailabilityParameters(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, name, type="Microsoft.Storage/storageAccounts", **kwargs): + def __init__(self, name, type="Microsoft.Storage/storageAccounts"): self.name = name self.type = type diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_create_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_create_parameters.py index d490562665d8b..1f5fe04cca5bc 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_create_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_create_parameters.py @@ -28,7 +28,7 @@ class StorageAccountCreateParameters(Model): 'properties': {'key': 'properties', 'type': 'StorageAccountPropertiesCreateParameters'}, } - def __init__(self, location, tags=None, properties=None, **kwargs): + def __init__(self, location, tags=None, properties=None): self.location = location self.tags = tags self.properties = properties diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_keys.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_keys.py index 3bc0943541fc0..171d1d785f012 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_keys.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_keys.py @@ -20,6 +20,6 @@ class StorageAccountKeys(Model): 'key2': {'key': 'key2', 'type': 'str'}, } - def __init__(self, key1=None, key2=None, **kwargs): + def __init__(self, key1=None, key2=None): self.key1 = key1 self.key2 = key2 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 cb58445a1ce39..2259b66353acf 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 @@ -69,7 +69,7 @@ class StorageAccountProperties(Model): 'secondary_endpoints': {'key': 'secondaryEndpoints', 'type': 'Endpoints'}, } - def __init__(self, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None, **kwargs): + def __init__(self, provisioning_state=None, account_type=None, primary_endpoints=None, primary_location=None, status_of_primary=None, last_geo_failover_time=None, secondary_location=None, status_of_secondary=None, creation_time=None, custom_domain=None, secondary_endpoints=None): self.provisioning_state = provisioning_state self.account_type = account_type self.primary_endpoints = primary_endpoints 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 4d69da5caf759..b2d63195ed800 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 @@ -22,5 +22,5 @@ class StorageAccountPropertiesCreateParameters(Model): 'account_type': {'key': 'accountType', 'type': 'AccountType'}, } - def __init__(self, account_type, **kwargs): + def __init__(self, account_type): self.account_type = account_type 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 9a5fbc12e1783..a9a27ddebd2c1 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 @@ -26,6 +26,6 @@ class StorageAccountPropertiesUpdateParameters(Model): 'custom_domain': {'key': 'customDomain', 'type': 'CustomDomain'}, } - def __init__(self, account_type=None, custom_domain=None, **kwargs): + def __init__(self, account_type=None, custom_domain=None): self.account_type = account_type self.custom_domain = custom_domain diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_regenerate_key_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_regenerate_key_parameters.py index 04c4ce47cf68b..057ea3a49177e 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_regenerate_key_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_regenerate_key_parameters.py @@ -20,5 +20,5 @@ class StorageAccountRegenerateKeyParameters(Model): 'key_name': {'key': 'keyName', 'type': 'str'}, } - def __init__(self, key_name, **kwargs): + def __init__(self, key_name): self.key_name = key_name diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_update_parameters.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_update_parameters.py index f339b37d57d36..39c5cd78d1599 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_update_parameters.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/storage_account_update_parameters.py @@ -21,6 +21,6 @@ class StorageAccountUpdateParameters(Model): 'properties': {'key': 'properties', 'type': 'StorageAccountPropertiesUpdateParameters'}, } - def __init__(self, tags=None, properties=None, **kwargs): + def __init__(self, tags=None, properties=None): self.tags = tags self.properties = properties diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py index aa81987351d9c..a22a532456d2c 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage.py @@ -37,7 +37,7 @@ class Usage(Model): 'name': {'key': 'name', 'type': 'UsageName'}, } - def __init__(self, unit, current_value, limit, name, **kwargs): + def __init__(self, unit, current_value, limit, name): self.unit = unit self.current_value = current_value self.limit = limit diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage_name.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage_name.py index 3477988bfbb5c..5edfc23c328e0 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage_name.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/models/usage_name.py @@ -21,6 +21,6 @@ class UsageName(Model): 'localized_value': {'key': 'localizedValue', 'type': 'str'}, } - def __init__(self, value=None, localized_value=None, **kwargs): + def __init__(self, value=None, localized_value=None): self.value = value self.localized_value = localized_value diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py index 732eb30e70fb2..00031c87fca75 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py @@ -43,9 +43,15 @@ def __init__( self, credentials, subscription_id, api_version='2015-06-15', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): if credentials is None: - raise ValueError('credentials must not be None.') + raise ValueError("Parameter 'credentials' must not be None.") if subscription_id is None: - raise ValueError('subscription_id must not be None.') + raise ValueError("Parameter 'subscription_id' must not be None.") + if not isinstance(subscription_id, str): + raise TypeError("Parameter 'subscription_id' must be str.") + if api_version is not None and not isinstance(api_version, str): + raise TypeError("Optional parameter 'api_version' must be str.") + if accept_language is not None and not isinstance(accept_language, str): + raise TypeError("Optional parameter 'accept_language' must be str.") if not base_url: base_url = 'https://management.azure.com' diff --git a/Samples/petstore/Python/setup.py b/Samples/petstore/Python/setup.py index f1c57ff21b2c6..bd6e6ed040665 100644 --- a/Samples/petstore/Python/setup.py +++ b/Samples/petstore/Python/setup.py @@ -15,7 +15,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.1.0"] +REQUIRES = ["msrest>=0.2.0"] setup( name=NAME, diff --git a/Samples/petstore/Python/swaggerpetstore/models/category.py b/Samples/petstore/Python/swaggerpetstore/models/category.py index 274c76da920e0..70aae7c8f0d90 100644 --- a/Samples/petstore/Python/swaggerpetstore/models/category.py +++ b/Samples/petstore/Python/swaggerpetstore/models/category.py @@ -19,6 +19,6 @@ class Category(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, name=None, **kwargs): + def __init__(self, id=None, name=None): self.id = id self.name = name diff --git a/Samples/petstore/Python/swaggerpetstore/models/order.py b/Samples/petstore/Python/swaggerpetstore/models/order.py index e02faeb1811a7..8b7b27a2bbe96 100644 --- a/Samples/petstore/Python/swaggerpetstore/models/order.py +++ b/Samples/petstore/Python/swaggerpetstore/models/order.py @@ -32,7 +32,7 @@ class Order(Model): 'complete': {'key': 'complete', 'type': 'bool'}, } - def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=None, **kwargs): + def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=None): self.id = id self.pet_id = pet_id self.quantity = quantity diff --git a/Samples/petstore/Python/swaggerpetstore/models/pet.py b/Samples/petstore/Python/swaggerpetstore/models/pet.py index eea3cb945d5af..3c01b6a3ba08d 100644 --- a/Samples/petstore/Python/swaggerpetstore/models/pet.py +++ b/Samples/petstore/Python/swaggerpetstore/models/pet.py @@ -37,7 +37,7 @@ class Pet(Model): 'status': {'key': 'status', 'type': 'str'}, } - def __init__(self, name, photo_urls, id=None, category=None, tags=None, status=None, **kwargs): + def __init__(self, name, photo_urls, id=None, category=None, tags=None, status=None): self.id = id self.category = category self.name = name diff --git a/Samples/petstore/Python/swaggerpetstore/models/tag.py b/Samples/petstore/Python/swaggerpetstore/models/tag.py index 34b6460af1321..38d4ffbabcd1f 100644 --- a/Samples/petstore/Python/swaggerpetstore/models/tag.py +++ b/Samples/petstore/Python/swaggerpetstore/models/tag.py @@ -19,6 +19,6 @@ class Tag(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, id=None, name=None, **kwargs): + def __init__(self, id=None, name=None): self.id = id self.name = name diff --git a/Samples/petstore/Python/swaggerpetstore/models/user.py b/Samples/petstore/Python/swaggerpetstore/models/user.py index ce6eeadc63758..17d843abff65b 100644 --- a/Samples/petstore/Python/swaggerpetstore/models/user.py +++ b/Samples/petstore/Python/swaggerpetstore/models/user.py @@ -37,7 +37,7 @@ class User(Model): 'user_status': {'key': 'userStatus', 'type': 'int'}, } - def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None, **kwargs): + def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): self.id = id self.username = username self.first_name = first_name diff --git a/gulpfile.js b/gulpfile.js index 46785dfa21046..e7bc6be0adf4a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -63,7 +63,8 @@ var defaultMappings = { 'AcceptanceTests/Url': '../../../TestServer/swagger/url.json', 'AcceptanceTests/Validation': '../../../TestServer/swagger/validation.json', 'AcceptanceTests/CustomBaseUri': '../../../TestServer/swagger/custom-baseUrl.json', - 'AcceptanceTests/ModelFlattening': '../../../TestServer/swagger/model-flattening.json', + 'AcceptanceTests/CustomBaseUriMoreOptions': '../../../TestServer/swagger/custom-baseUrl-more-options.json', + 'AcceptanceTests/ModelFlattening': '../../../TestServer/swagger/model-flattening.json' }; var rubyMappings = { @@ -411,13 +412,23 @@ gulp.task('regenerate:expected:samples:azure', function(){ } }); +var msBuildToolsVersion = 12.0; +if (isWindows) { + fs.readdirSync('C:/Program Files (x86)/MSBuild/').forEach(function (item) { + var itemAsFloat = parseFloat(item); + if (itemAsFloat > msBuildToolsVersion) { + msBuildToolsVersion = itemAsFloat; + } + }); +} + var msbuildDefaults = { stdout: process.stdout, stderr: process.stderr, maxBuffer: MAX_BUFFER, verbosity: 'minimal', errorOnFail: true, - toolsVersion: 12.0 + toolsVersion: msBuildToolsVersion }; gulp.task('clean:node_modules', function(cb) { diff --git a/schema/swagger-extensions.json b/schema/swagger-extensions.json index 199078f32eee3..6e6476c56dbf0 100644 --- a/schema/swagger-extensions.json +++ b/schema/swagger-extensions.json @@ -1540,6 +1540,15 @@ "hostTemplate": { "type": "string" }, + "useSchemePrefix": { + "type": "boolean", + "default": true + }, + "positionInOperation": { + "type": "string", + "default": "first", + "pattern": "^(fir|la)st$" + }, "parameters": { "$ref": "#/definitions/xmsHostParametersList" }