diff --git a/AutoRest/AutoRest.Core/AutoRest.nuget.proj b/AutoRest/AutoRest.Core/AutoRest.nuget.proj index 86429ba41f707..83546d434a8e4 100644 --- a/AutoRest/AutoRest.Core/AutoRest.nuget.proj +++ b/AutoRest/AutoRest.Core/AutoRest.nuget.proj @@ -2,7 +2,7 @@ - 0.16.0$(NightlyBuildVersion) + 0.17.0$(NightlyBuildVersion) true diff --git a/AutoRest/AutoRest.Core/Properties/AssemblyInfo.cs b/AutoRest/AutoRest.Core/Properties/AssemblyInfo.cs index aa48e093addc2..f1686e2433161 100644 --- a/AutoRest/AutoRest.Core/Properties/AssemblyInfo.cs +++ b/AutoRest/AutoRest.Core/Properties/AssemblyInfo.cs @@ -11,8 +11,8 @@ [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft AutoRest")] [assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] -[assembly: AssemblyVersion("0.16.0.0")] -[assembly: AssemblyFileVersion("0.16.0.0")] +[assembly: AssemblyVersion("0.17.0.0")] +[assembly: AssemblyFileVersion("0.17.0.0")] [assembly: NeutralResourcesLanguage("en")] [assembly: CLSCompliant(true)] diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs b/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs index e68eb4727a6dc..23080cb3a6797 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/AzureNodeJSCodeGenerator.cs @@ -18,7 +18,7 @@ namespace Microsoft.Rest.Generator.Azure.NodeJS { public class AzureNodeJSCodeGenerator : NodeJSCodeGenerator { - private const string ClientRuntimePackage = "ms-rest-azure version 1.13.1"; + private const string ClientRuntimePackage = "ms-rest-azure version 1.14.2"; // List of models with paging extensions. private IList pageModels; diff --git a/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs b/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs index 2e59314d876df..c25a4aff6ec00 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs +++ b/AutoRest/Generators/NodeJS/NodeJS/NodeJSCodeGenerator.cs @@ -16,7 +16,7 @@ namespace Microsoft.Rest.Generator.NodeJS { public class NodeJSCodeGenerator : CodeGenerator { - private const string ClientRuntimePackage = "ms-rest version 1.13.1"; + private const string ClientRuntimePackage = "ms-rest version 1.14.2"; public NodeJsCodeNamer Namer { get; private set; } diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_custom_base_uri_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_custom_base_uri_tests.py index c976b74e71e41..ba82c73fa906d 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_custom_base_uri_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_custom_base_uri_tests.py @@ -48,9 +48,7 @@ from msrest.exceptions import DeserializationError, SerializationError, ClientRequestError from msrest.authentication import BasicTokenAuthentication -from autorestparameterizedhosttestclient import ( - AutoRestParameterizedHostTestClient, - AutoRestParameterizedHostTestClientConfiguration) +from autorestparameterizedhosttestclient import AutoRestParameterizedHostTestClient from autorestparameterizedhosttestclient.exceptions import ValidationError from autorestparameterizedhosttestclient.models import Error, ErrorException @@ -60,19 +58,13 @@ class CustomBaseUriTests(unittest.TestCase): def test_custom_base_uri_positive(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestParameterizedHostTestClientConfiguration(cred, host="host:3000") - - config.log_level = log_level - client = AutoRestParameterizedHostTestClient(config) + client = AutoRestParameterizedHostTestClient(cred, host="host:3000") client.paths.get_empty("local") def test_custom_base_uri_negative(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestParameterizedHostTestClientConfiguration(cred, host="host:3000") - - config.log_level = log_level - config.retry_policy.retries = 0 - client = AutoRestParameterizedHostTestClient(config) + client = AutoRestParameterizedHostTestClient(cred, host="host:3000") + client.config.retry_policy.retries = 0 with self.assertRaises(ClientRequestError): client.paths.get_empty("bad") diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_url_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_url_tests.py index 9d142ace09c9a..bb9128e84f9b5 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_url_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/azure_url_tests.py @@ -48,9 +48,7 @@ from msrest.exceptions import DeserializationError from msrest.authentication import BasicTokenAuthentication -from microsoftazuretesturl import ( - MicrosoftAzureTestUrl, - MicrosoftAzureTestUrlConfiguration) +from microsoftazuretesturl import MicrosoftAzureTestUrl from microsoftazuretesturl.models import ErrorException, SampleResourceGroup @@ -62,10 +60,7 @@ def test_azure_url(self): client_id = str(uuid4()) cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = MicrosoftAzureTestUrlConfiguration(cred, sub_id, base_url="http://localhost:3000") - - config.log_level = log_level - client = MicrosoftAzureTestUrl(config) + client = MicrosoftAzureTestUrl(cred, sub_id, base_url="http://localhost:3000") group = client.group.get_sample_resource_group("testgoup101") self.assertEqual(group.name, "testgroup101") diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/duration_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/duration_tests.py index 92772e875a2cd..44f68c78789d1 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/duration_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/duration_tests.py @@ -48,9 +48,7 @@ from msrest.exceptions import DeserializationError from msrest.authentication import BasicTokenAuthentication -from autorestdurationtestservice import ( - AutoRestDurationTestService, - AutoRestDurationTestServiceConfiguration) +from autorestdurationtestservice import AutoRestDurationTestService class DurationTests(unittest.TestCase): @@ -58,9 +56,7 @@ class DurationTests(unittest.TestCase): def test_duration(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestDurationTestServiceConfiguration(cred, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestDurationTestService(config) + client = AutoRestDurationTestService(cred, base_url="http://localhost:3000") self.assertIsNone(client.duration.get_null()) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/head_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/head_tests.py index fe3ffda536882..bfbebb5e36bd1 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/head_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/head_tests.py @@ -50,23 +50,15 @@ from msrest.authentication import BasicTokenAuthentication from msrestazure.azure_exceptions import CloudError, CloudErrorData -from autorestheadtestservice import ( - AutoRestHeadTestService, - AutoRestHeadTestServiceConfiguration) - -from autorestheadexceptiontestservice import ( - AutoRestHeadExceptionTestService, - AutoRestHeadExceptionTestServiceConfiguration) +from autorestheadtestservice import AutoRestHeadTestService +from autorestheadexceptiontestservice import AutoRestHeadExceptionTestService class HeadTests(unittest.TestCase): def test_head(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestHeadTestServiceConfiguration(cred, base_url="http://localhost:3000") - - config.log_level = log_level - client = AutoRestHeadTestService(config) + client = AutoRestHeadTestService(cred, base_url="http://localhost:3000") self.assertTrue(client.http_success.head200()) self.assertTrue(client.http_success.head204()) @@ -77,10 +69,7 @@ class HeadExceptionTest(unittest.TestCase): def test_head_exception(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestHeadExceptionTestServiceConfiguration(cred, base_url="http://localhost:3000") - - config.log_level = log_level - client = AutoRestHeadExceptionTestService(config) + client = AutoRestHeadExceptionTestService(cred, base_url="http://localhost:3000") client.head_exception.head200() client.head_exception.head204() diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/lro_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/lro_tests.py index 7e52e686bda1a..39ef060fbe527 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/lro_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/lro_tests.py @@ -49,10 +49,7 @@ from msrest.authentication import BasicTokenAuthentication from msrestazure.azure_exceptions import CloudError, CloudErrorData -from autorestlongrunningoperationtestservice import ( - AutoRestLongRunningOperationTestService, - AutoRestLongRunningOperationTestServiceConfiguration) - +from autorestlongrunningoperationtestservice import AutoRestLongRunningOperationTestService from autorestlongrunningoperationtestservice.models import * class LroTests(unittest.TestCase): @@ -60,10 +57,7 @@ class LroTests(unittest.TestCase): def setUp(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestLongRunningOperationTestServiceConfiguration(cred, base_url="http://localhost:3000") - - config.log_level = log_level - self.client = AutoRestLongRunningOperationTestService(config) + self.client = AutoRestLongRunningOperationTestService(cred, base_url="http://localhost:3000") self.client.config.long_running_operation_timeout = 0 self.client._client._adapter.add_hook("request", self.client._client._adapter._test_pipeline) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py index 115c5278b1145..38b4c3391bda8 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/paging_tests.py @@ -49,18 +49,14 @@ from msrestazure.azure_exceptions import CloudError from msrest.authentication import BasicTokenAuthentication -from autorestpagingtestservice import ( - AutoRestPagingTestService, - AutoRestPagingTestServiceConfiguration) +from autorestpagingtestservice import AutoRestPagingTestService from autorestpagingtestservice.models import PagingGetMultiplePagesWithOffsetOptions class PagingTests(unittest.TestCase): def setUp(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestPagingTestServiceConfiguration(cred, base_url="http://localhost:3000") - config.log_level = log_level - self.client = AutoRestPagingTestService(config) + self.client = AutoRestPagingTestService(cred, base_url="http://localhost:3000") self.client._client._adapter.add_hook("request", self.client._client._adapter._test_pipeline) return super(PagingTests, self).setUp() diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/parameter_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/parameter_tests.py index 56b5b87993e26..b0bac37f2bb2c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/parameter_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/parameter_tests.py @@ -49,13 +49,17 @@ sys.path.append(join(tests, "AzureSpecials")) from msrest.exceptions import DeserializationError -from autorestparametergroupingtestservice import AutoRestParameterGroupingTestServiceConfiguration, AutoRestParameterGroupingTestService -from microsoftazuretesturl import MicrosoftAzureTestUrl, MicrosoftAzureTestUrlConfiguration -from autorestdurationtestservice import AutoRestDurationTestService, AutoRestDurationTestServiceConfiguration -from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient, AutoRestAzureSpecialParametersTestClientConfiguration +from autorestparametergroupingtestservice import AutoRestParameterGroupingTestService +from microsoftazuretesturl import MicrosoftAzureTestUrl +from autorestdurationtestservice import AutoRestDurationTestService +from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient from autorestparameterizedhosttestclient.exceptions import ValidationError -from autorestparametergroupingtestservice.models import ParameterGroupingPostMultiParamGroupsSecondParamGroup, ParameterGroupingPostOptionalParameters, ParameterGroupingPostRequiredParameters, FirstParameterGroup +from autorestparametergroupingtestservice.models import ( + ParameterGroupingPostMultiParamGroupsSecondParamGroup, + ParameterGroupingPostOptionalParameters, + ParameterGroupingPostRequiredParameters, + FirstParameterGroup) from msrest.authentication import BasicTokenAuthentication @@ -71,9 +75,7 @@ def test_parameter_grouping(self): pathParameter = 'path' cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestParameterGroupingTestServiceConfiguration(cred, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestParameterGroupingTestService(config) + client = AutoRestParameterGroupingTestService(cred, base_url="http://localhost:3000") # Valid required parameters requiredParameters = ParameterGroupingPostRequiredParameters(body=bodyParameter, path=pathParameter, custom_header=headerParameter, query=queryParameter) @@ -118,9 +120,7 @@ def test_azure_special_parameters(self): unencodedPath = 'path1/path2/path3' unencodedQuery = 'value1&q2=value2&q3=value3' cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") client.subscription_in_credentials.post_method_global_not_provided_valid() client.subscription_in_credentials.post_method_global_valid() @@ -154,9 +154,7 @@ def test_azure_odata(self): validSubscription = '1234-5678-9012-3456' cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") client.odata.get_with_filter(filter="id gt 5 and name eq 'foo'", top=10, orderby="id") diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py index f59b4bec7a249..32b33bf21a195 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/xms_request_clientid_tests.py @@ -49,7 +49,7 @@ from msrest.authentication import BasicTokenAuthentication from msrestazure.azure_exceptions import CloudError, CloudErrorData -from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient, AutoRestAzureSpecialParametersTestClientConfiguration +from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient class XmsRequestClientIdTests(unittest.TestCase): @@ -60,9 +60,7 @@ def test_xms_request_client_id(self): validClientId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0' cred = BasicTokenAuthentication({"access_token":123}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") custom_headers = {"x-ms-client-request-id": validClientId } @@ -79,9 +77,7 @@ def test_custom_named_request_id(self): expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0' cred = BasicTokenAuthentication({"access_token":123}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") response = client.header.custom_named_request_id(expectedRequestId, raw=True) self.assertEqual("123", response.response.headers.get("foo-request-id")) @@ -91,9 +87,7 @@ def test_client_request_id_in_exception(self): expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0' cred = BasicTokenAuthentication({"access_token":123}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") try: client.xms_client_request_id.get() @@ -107,10 +101,8 @@ def test_xms_request_client_id_in_client(self): expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0' cred = BasicTokenAuthentication({"access_token":123}) - config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000") - config.log_level = log_level - config.generate_client_request_id = False - client = AutoRestAzureSpecialParametersTestClient(config) + client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000") + client.config.generate_client_request_id = False client.xms_client_request_id.get() diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/zzz_tests.py b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/zzz_tests.py index bb87f7a73531e..76a9832a022b7 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/zzz_tests.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/AcceptanceTests/zzz_tests.py @@ -47,7 +47,7 @@ from msrest.exceptions import DeserializationError -from autorestreportserviceforazure import AutoRestReportServiceForAzureConfiguration, AutoRestReportServiceForAzure +from autorestreportserviceforazure import AutoRestReportServiceForAzure from msrest.authentication import BasicTokenAuthentication @@ -57,9 +57,7 @@ class AcceptanceTests(unittest.TestCase): def test_ensure_coverage(self): cred = BasicTokenAuthentication({"access_token" :str(uuid4())}) - config = AutoRestReportServiceForAzureConfiguration(cred, base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestReportServiceForAzure(config) + client = AutoRestReportServiceForAzure(cred, base_url="http://localhost:3000") report = client.get_report() skipped = [k for k, v in report.items() if v == 0] diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/__init__.py index 2b089964f917f..4ec26f57486df 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_duration_test_service import AutoRestDurationTestService, AutoRestDurationTestServiceConfiguration +from .auto_rest_duration_test_service import AutoRestDurationTestService from .version import VERSION -__all__ = [ - 'AutoRestDurationTestService', - 'AutoRestDurationTestServiceConfiguration' -] +__all__ = ['AutoRestDurationTestService'] __version__ = VERSION 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 668b135381e1f..c0d65d8ae7949 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 @@ -63,21 +63,38 @@ def __init__( class AutoRestDurationTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestDurationTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestDurationTestServiceConfiguration :ivar duration: Duration operations :vartype duration: .operations.DurationOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestDurationTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.duration = DurationOperations( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/operations/duration_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/operations/duration_operations.py index 255f4e6b66f4c..db838547b4929 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/operations/duration_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureBodyDuration/autorestdurationtestservice/operations/duration_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null duration value @@ -81,7 +81,7 @@ def get_null( return deserialized def put_positive_duration( - self, duration_body, custom_headers={}, raw=False, **operation_config): + self, duration_body, custom_headers=None, raw=False, **operation_config): """ Put a positive duration value @@ -128,7 +128,7 @@ def put_positive_duration( return client_raw_response def get_positive_duration( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a positive duration value @@ -176,7 +176,7 @@ def get_positive_duration( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an invalid duration value diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/__init__.py index 3ebb42c766ef0..375abf70c5f95 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService, AutoRestParameterGroupingTestServiceConfiguration +from .auto_rest_parameter_grouping_test_service import AutoRestParameterGroupingTestService from .version import VERSION -__all__ = [ - 'AutoRestParameterGroupingTestService', - 'AutoRestParameterGroupingTestServiceConfiguration' -] +__all__ = ['AutoRestParameterGroupingTestService'] __version__ = VERSION 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 13e63f9569c81..6e0264658e5e7 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 @@ -63,21 +63,38 @@ def __init__( class AutoRestParameterGroupingTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestParameterGroupingTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestParameterGroupingTestServiceConfiguration :ivar parameter_grouping: ParameterGrouping operations :vartype parameter_grouping: .operations.ParameterGroupingOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestParameterGroupingTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.parameter_grouping = ParameterGroupingOperations( self._client, self.config, self._serialize, self._deserialize) 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 172a4349ff36c..dec4f136004f7 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/first_parameter_group.py @@ -14,9 +14,7 @@ class FirstParameterGroup(Model): """ - Additional parameters for a set of operations, such as: - parameterGrouping_postMultiParamGroups, - parameterGrouping_postSharedParameterGroupObject. + Additional parameters for one or more operations :param header_one: :type header_one: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py index bccdfab25480f..4d4af238358bc 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_multi_param_groups_second_param_group.py @@ -14,8 +14,7 @@ class ParameterGroupingPostMultiParamGroupsSecondParamGroup(Model): """ - Additional parameters for the parameterGrouping_postMultiParamGroups - operation. + Additional parameters for one or more operations :param header_two: :type header_two: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py index a62313adf9a27..623b79fd0feee 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_optional_parameters.py @@ -14,7 +14,7 @@ class ParameterGroupingPostOptionalParameters(Model): """ - Additional parameters for the parameterGrouping_postOptional operation. + Additional parameters for one or more operations :param custom_header: :type custom_header: str diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py index 409f4ffcdcf26..109ebe5ad51e0 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/models/parameter_grouping_post_required_parameters.py @@ -14,7 +14,7 @@ class ParameterGroupingPostRequiredParameters(Model): """ - Additional parameters for the parameterGrouping_postRequired operation. + Additional parameters for one or more operations :param body: :type body: int diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/operations/parameter_grouping_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/operations/parameter_grouping_operations.py index 673a139143350..27541e740ed89 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/operations/parameter_grouping_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autorestparametergroupingtestservice/operations/parameter_grouping_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def post_required( - self, parameter_grouping_post_required_parameters, custom_headers={}, raw=False, **operation_config): + self, parameter_grouping_post_required_parameters, custom_headers=None, raw=False, **operation_config): """ Post a bunch of required parameters grouped @@ -104,7 +104,7 @@ def post_required( return client_raw_response def post_optional( - self, parameter_grouping_post_optional_parameters=None, custom_headers={}, raw=False, **operation_config): + self, parameter_grouping_post_optional_parameters=None, custom_headers=None, raw=False, **operation_config): """ Post a bunch of optional parameters grouped @@ -161,7 +161,7 @@ def post_optional( return client_raw_response def post_multi_param_groups( - self, first_parameter_group=None, parameter_grouping_post_multi_param_groups_second_param_group=None, custom_headers={}, raw=False, **operation_config): + self, first_parameter_group=None, parameter_grouping_post_multi_param_groups_second_param_group=None, custom_headers=None, raw=False, **operation_config): """ Post parameters from multiple different parameter groups @@ -231,7 +231,7 @@ def post_multi_param_groups( return client_raw_response def post_shared_parameter_group_object( - self, first_parameter_group=None, custom_headers={}, raw=False, **operation_config): + self, first_parameter_group=None, custom_headers=None, raw=False, **operation_config): """ Post parameters with a shared parameter group object diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/__init__.py index 3b5e0464d00a4..c038eb8a5dcb4 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureReport/autorestreportserviceforazure/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_report_service_for_azure import AutoRestReportServiceForAzure, AutoRestReportServiceForAzureConfiguration +from .auto_rest_report_service_for_azure import AutoRestReportServiceForAzure from .version import VERSION -__all__ = [ - 'AutoRestReportServiceForAzure', - 'AutoRestReportServiceForAzureConfiguration' -] +__all__ = ['AutoRestReportServiceForAzure'] __version__ = VERSION 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 c02088e43b1a4..202ecaa8ad4b9 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 @@ -64,22 +64,39 @@ def __init__( class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestReportServiceForAzureConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestReportServiceForAzureConfiguration + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestReportServiceForAzureConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def get_report( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get test coverage report diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/__init__.py index a81829bba4a6a..f01b0f4d27100 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureResource/autorestresourceflatteningtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService, AutoRestResourceFlatteningTestServiceConfiguration +from .auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService from .version import VERSION -__all__ = [ - 'AutoRestResourceFlatteningTestService', - 'AutoRestResourceFlatteningTestServiceConfiguration' -] +__all__ = ['AutoRestResourceFlatteningTestService'] __version__ = VERSION 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 74f09db9d3400..4efa7f43c5937 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 @@ -64,22 +64,39 @@ def __init__( class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest - :param config: Configuration for client. - :type config: AutoRestResourceFlatteningTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestResourceFlatteningTestServiceConfiguration + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestResourceFlatteningTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def put_array( - self, resource_array=None, custom_headers={}, raw=False, **operation_config): + self, resource_array=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as an Array @@ -130,7 +147,7 @@ def put_array( return client_raw_response def get_array( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as an Array @@ -179,7 +196,7 @@ def get_array( return deserialized def put_dictionary( - self, resource_dictionary=None, custom_headers={}, raw=False, **operation_config): + self, resource_dictionary=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as a Dictionary @@ -229,7 +246,7 @@ def put_dictionary( return client_raw_response def get_dictionary( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as a Dictionary @@ -277,7 +294,7 @@ def get_dictionary( return deserialized def put_resource_collection( - self, resource_complex_object=None, custom_headers={}, raw=False, **operation_config): + self, resource_complex_object=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as a ResourceCollection @@ -329,7 +346,7 @@ def put_resource_collection( return client_raw_response def get_resource_collection( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as a ResourceCollection diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/__init__.py index 99cf572f3c11d..17626ce777bc5 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient, AutoRestAzureSpecialParametersTestClientConfiguration +from .auto_rest_azure_special_parameters_test_client import AutoRestAzureSpecialParametersTestClient from .version import VERSION -__all__ = [ - 'AutoRestAzureSpecialParametersTestClient', - 'AutoRestAzureSpecialParametersTestClientConfiguration' -] +__all__ = ['AutoRestAzureSpecialParametersTestClient'] __version__ = VERSION 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 95f2d47d0fb58..1c7d3213c7017 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 @@ -84,8 +84,8 @@ def __init__( class AutoRestAzureSpecialParametersTestClient(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestAzureSpecialParametersTestClientConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestAzureSpecialParametersTestClientConfiguration :ivar xms_client_request_id: XMsClientRequestId operations :vartype xms_client_request_id: .operations.XMsClientRequestIdOperations @@ -103,17 +103,40 @@ class AutoRestAzureSpecialParametersTestClient(object): :vartype odata: .operations.OdataOperations :ivar header: Header operations :vartype header: .operations.HeaderOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The subscription id, which appears in the path, + always modeled in credentials. The value is always '1234-5678-9012-3456' + :type subscription_id: str + :param api_version: The api version, which appears in the query, the + value is always '2015-07-01-preview' + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + 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): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestAzureSpecialParametersTestClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.xms_client_request_id = XMsClientRequestIdOperations( self._client, self.config, self._serialize, self._deserialize) self.subscription_in_credentials = SubscriptionInCredentialsOperations( diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_default_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_default_operations.py index 77db1896b33a0..874e55a3cf605 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_default_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_default_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_method_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ GET method with api-version modeled in global settings. @@ -75,7 +75,7 @@ def get_method_global_valid( return client_raw_response def get_method_global_not_provided_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ GET method with api-version modeled in global settings. @@ -117,7 +117,7 @@ def get_method_global_not_provided_valid( return client_raw_response def get_path_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ GET method with api-version modeled in global settings. @@ -159,7 +159,7 @@ def get_path_global_valid( return client_raw_response def get_swagger_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ GET method with api-version modeled in global settings. diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_local_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_local_operations.py index 7ba723b1f3672..e5b30970f173e 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_local_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/api_version_local_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_method_local_valid( - self, api_version="2.0", custom_headers={}, raw=False, **operation_config): + self, api_version="2.0", custom_headers=None, raw=False, **operation_config): """ Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed @@ -79,7 +79,7 @@ def get_method_local_valid( return client_raw_response def get_method_local_null( - self, api_version=None, custom_headers={}, raw=False, **operation_config): + self, api_version=None, custom_headers=None, raw=False, **operation_config): """ Get method with api-version modeled in the method. pass in api-version = null to succeed @@ -126,7 +126,7 @@ def get_method_local_null( return client_raw_response def get_path_local_valid( - self, api_version="2.0", custom_headers={}, raw=False, **operation_config): + self, api_version="2.0", custom_headers=None, raw=False, **operation_config): """ Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed @@ -172,7 +172,7 @@ def get_path_local_valid( return client_raw_response def get_swagger_local_valid( - self, api_version="2.0", custom_headers={}, raw=False, **operation_config): + self, api_version="2.0", custom_headers=None, raw=False, **operation_config): """ Get method with api-version modeled in the method. pass in api-version = '2.0' to succeed diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py index c25794e67a228..3900422185422 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/header_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def custom_named_request_id( - self, foo_client_request_id, custom_headers={}, raw=False, **operation_config): + self, foo_client_request_id, custom_headers=None, raw=False, **operation_config): """ Send foo-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/odata_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/odata_operations.py index fb33e1238a785..efff53fb99807 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/odata_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/odata_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_with_filter( - self, filter=None, top=None, orderby=None, custom_headers={}, raw=False, **operation_config): + self, filter=None, top=None, orderby=None, custom_headers=None, raw=False, **operation_config): """ Specify filter parameter with value '$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/skip_url_encoding_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/skip_url_encoding_operations.py index 3e289ed433304..b657cd53af1ce 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/skip_url_encoding_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/skip_url_encoding_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_method_path_valid( - self, unencoded_path_param, custom_headers={}, raw=False, **operation_config): + self, unencoded_path_param, custom_headers=None, raw=False, **operation_config): """ Get method with unencoded path parameter with value 'path1/path2/path3' @@ -81,7 +81,7 @@ def get_method_path_valid( return client_raw_response def get_path_path_valid( - self, unencoded_path_param, custom_headers={}, raw=False, **operation_config): + self, unencoded_path_param, custom_headers=None, raw=False, **operation_config): """ Get method with unencoded path parameter with value 'path1/path2/path3' @@ -129,7 +129,7 @@ def get_path_path_valid( return client_raw_response def get_swagger_path_valid( - self, unencoded_path_param="path1/path2/path3", custom_headers={}, raw=False, **operation_config): + self, unencoded_path_param="path1/path2/path3", custom_headers=None, raw=False, **operation_config): """ Get method with unencoded path parameter with value 'path1/path2/path3' @@ -177,7 +177,7 @@ def get_swagger_path_valid( return client_raw_response def get_method_query_valid( - self, q1, custom_headers={}, raw=False, **operation_config): + self, q1, custom_headers=None, raw=False, **operation_config): """ Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3' @@ -223,7 +223,7 @@ def get_method_query_valid( return client_raw_response def get_method_query_null( - self, q1=None, custom_headers={}, raw=False, **operation_config): + self, q1=None, custom_headers=None, raw=False, **operation_config): """ Get method with unencoded query parameter with value null @@ -268,7 +268,7 @@ def get_method_query_null( return client_raw_response def get_path_query_valid( - self, q1, custom_headers={}, raw=False, **operation_config): + self, q1, custom_headers=None, raw=False, **operation_config): """ Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3' @@ -314,7 +314,7 @@ def get_path_query_valid( return client_raw_response def get_swagger_query_valid( - self, q1="value1&q2=value2&q3=value3", custom_headers={}, raw=False, **operation_config): + self, q1="value1&q2=value2&q3=value3", custom_headers=None, raw=False, **operation_config): """ Get method with unencoded query parameter with value 'value1&q2=value2&q3=value3' diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_credentials_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_credentials_operations.py index 7a1f0e632f95a..b14e40ea2582a 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_credentials_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_credentials_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def post_method_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to '1234-5678-9012-3456' to succeed @@ -79,7 +79,7 @@ def post_method_global_valid( return client_raw_response def post_method_global_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to null, and client-side validation should @@ -126,7 +126,7 @@ def post_method_global_null( return client_raw_response def post_method_global_not_provided_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to '1234-5678-9012-3456' to succeed @@ -173,7 +173,7 @@ def post_method_global_not_provided_valid( return client_raw_response def post_path_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to '1234-5678-9012-3456' to succeed @@ -219,7 +219,7 @@ def post_path_global_valid( return client_raw_response def post_swagger_global_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in credentials. Set the credential subscriptionId to '1234-5678-9012-3456' to succeed diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_method_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_method_operations.py index a10cf1f70b7e8..9386906cae198 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_method_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/subscription_in_method_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def post_method_local_valid( - self, subscription_id, custom_headers={}, raw=False, **operation_config): + self, subscription_id, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in the method. pass in subscription id = '1234-5678-9012-3456' to succeed @@ -82,7 +82,7 @@ def post_method_local_valid( return client_raw_response def post_method_local_null( - self, subscription_id, custom_headers={}, raw=False, **operation_config): + self, subscription_id, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in the method. pass in subscription id = null, client-side validation should prevent you @@ -132,7 +132,7 @@ def post_method_local_null( return client_raw_response def post_path_local_valid( - self, subscription_id, custom_headers={}, raw=False, **operation_config): + self, subscription_id, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in the method. pass in subscription id = '1234-5678-9012-3456' to succeed @@ -181,7 +181,7 @@ def post_path_local_valid( return client_raw_response def post_swagger_local_valid( - self, subscription_id, custom_headers={}, raw=False, **operation_config): + self, subscription_id, custom_headers=None, raw=False, **operation_config): """ POST method with subscriptionId modeled in the method. pass in subscription id = '1234-5678-9012-3456' to succeed diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/xms_client_request_id_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/xms_client_request_id_operations.py index 03f60b4d3ea06..d68315d8359f2 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/xms_client_request_id_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/AzureSpecials/autorestazurespecialparameterstestclient/operations/xms_client_request_id_operations.py @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get method that overwrites x-ms-client-request header with value 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. @@ -78,7 +78,7 @@ def get( return client_raw_response def param_get( - self, x_ms_client_request_id, custom_headers={}, raw=False, **operation_config): + self, x_ms_client_request_id, custom_headers=None, raw=False, **operation_config): """ Get method that overwrites x-ms-client-request header with value 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0. diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py index ba883e5e5ac44..55019b8878d29 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient, AutoRestParameterizedHostTestClientConfiguration +from .auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient from .version import VERSION -__all__ = [ - 'AutoRestParameterizedHostTestClient', - 'AutoRestParameterizedHostTestClientConfiguration' -] +__all__ = ['AutoRestParameterizedHostTestClient'] __version__ = VERSION 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 79e862f82db73..5c9a07ff0f558 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 @@ -69,21 +69,40 @@ def __init__( class AutoRestParameterizedHostTestClient(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestParameterizedHostTestClientConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestParameterizedHostTestClientConfiguration :ivar paths: Paths operations :vartype paths: .operations.PathsOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param host: A string value that is used as a global part of the + parameterized host + :type host: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, host, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestParameterizedHostTestClientConfiguration(credentials, host, accept_language, long_running_operation_retry_timeout, generate_client_request_id, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.paths = PathsOperations( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths_operations.py index a7aaf4792f2e6..3e293149bc4e7 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_empty( - self, account_name, custom_headers={}, raw=False, **operation_config): + self, account_name, custom_headers=None, raw=False, **operation_config): """ Get a 200 to test a valid base uri diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/__init__.py index ce653b3b55a8e..6413c91141662 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_head_test_service import AutoRestHeadTestService, AutoRestHeadTestServiceConfiguration +from .auto_rest_head_test_service import AutoRestHeadTestService from .version import VERSION -__all__ = [ - 'AutoRestHeadTestService', - 'AutoRestHeadTestServiceConfiguration' -] +__all__ = ['AutoRestHeadTestService'] __version__ = VERSION 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 fc86a3308cb2e..6d2a167e2356d 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 @@ -62,21 +62,38 @@ def __init__( class AutoRestHeadTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestHeadTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestHeadTestServiceConfiguration :ivar http_success: HttpSuccess operations :vartype http_success: .operations.HttpSuccessOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestHeadTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.http_success = HttpSuccessOperations( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/operations/http_success_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/operations/http_success_operations.py index e490d4818d397..8f14a81b39a37 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/operations/http_success_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Head/autorestheadtestservice/operations/http_success_operations.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 200 status code if successful @@ -77,7 +77,7 @@ def head200( return deserialized def head204( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 204 status code if successful @@ -122,7 +122,7 @@ def head204( return deserialized def head404( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 404 status code if successful diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/__init__.py index 3ab0679689ddc..0e63032ad6984 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService, AutoRestHeadExceptionTestServiceConfiguration +from .auto_rest_head_exception_test_service import AutoRestHeadExceptionTestService from .version import VERSION -__all__ = [ - 'AutoRestHeadExceptionTestService', - 'AutoRestHeadExceptionTestServiceConfiguration' -] +__all__ = ['AutoRestHeadExceptionTestService'] __version__ = VERSION 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 d9745572729ef..833ddcb297cd7 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 @@ -62,21 +62,38 @@ def __init__( class AutoRestHeadExceptionTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestHeadExceptionTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestHeadExceptionTestServiceConfiguration :ivar head_exception: HeadException operations :vartype head_exception: .operations.HeadExceptionOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestHeadExceptionTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.head_exception = HeadExceptionOperations( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/operations/head_exception_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/operations/head_exception_operations.py index 4d7d386b49193..65669404b4d1d 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/operations/head_exception_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/HeadExceptions/autorestheadexceptiontestservice/operations/head_exception_operations.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 200 status code if successful @@ -75,7 +75,7 @@ def head200( return client_raw_response def head204( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 204 status code if successful @@ -118,7 +118,7 @@ def head204( return client_raw_response def head404( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 404 status code if successful diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/__init__.py index 8186c26cc15cc..eb1578e8c7c95 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService, AutoRestLongRunningOperationTestServiceConfiguration +from .auto_rest_long_running_operation_test_service import AutoRestLongRunningOperationTestService from .version import VERSION -__all__ = [ - 'AutoRestLongRunningOperationTestService', - 'AutoRestLongRunningOperationTestServiceConfiguration' -] +__all__ = ['AutoRestLongRunningOperationTestService'] __version__ = VERSION 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 be1ddc0cc63c0..68a1caef5b1a3 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 @@ -66,8 +66,8 @@ def __init__( class AutoRestLongRunningOperationTestService(object): """Long-running Operation for AutoRest - :param config: Configuration for client. - :type config: AutoRestLongRunningOperationTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestLongRunningOperationTestServiceConfiguration :ivar lr_os: LROs operations :vartype lr_os: .operations.LROsOperations @@ -77,17 +77,34 @@ class AutoRestLongRunningOperationTestService(object): :vartype lrosa_ds: .operations.LROSADsOperations :ivar lr_os_custom_header: LROsCustomHeader operations :vartype lr_os_custom_header: .operations.LROsCustomHeaderOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestLongRunningOperationTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.lr_os = LROsOperations( self._client, self.config, self._serialize, self._deserialize) self.lro_retrys = LRORetrysOperations( diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_custom_header_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_custom_header_operations.py index 96ade6d8e3ad8..105c79d96f2d1 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_custom_header_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_custom_header_operations.py @@ -35,7 +35,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def put_async_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, @@ -85,10 +85,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -129,7 +130,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put201_creating_succeeded200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, @@ -179,10 +180,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -218,7 +220,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_retry200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, @@ -267,10 +269,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -301,7 +304,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, @@ -350,10 +353,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_operations.py index 4a078a8a86f8f..00a39dccab75c 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lr_os_operations.py @@ -35,7 +35,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def put200_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Succeeded’. @@ -82,10 +82,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -119,7 +120,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put200_succeeded_no_state( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that does not contain @@ -167,10 +168,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -204,7 +206,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put202_retry200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 202 to the initial request, with a location header that points to a polling URL that @@ -252,10 +254,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -289,7 +292,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put201_creating_succeeded200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -338,10 +341,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -377,7 +381,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put200_updating_succeeded204( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Updating’. @@ -426,10 +430,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -463,7 +468,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put201_creating_failed200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Created’. @@ -512,10 +517,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -551,7 +557,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put200_acceptedcanceled200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -600,10 +606,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -637,7 +644,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_no_header_in_retry( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 202 to the initial request with location header. Subsequent calls to operation status do not @@ -685,10 +692,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -727,7 +735,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -776,10 +784,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -820,7 +829,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_no_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -869,10 +878,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -912,7 +922,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_retry_failed( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -961,10 +971,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1005,7 +1016,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_no_retrycanceled( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1054,10 +1065,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1097,7 +1109,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_no_header_in_retry( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 202 to the initial request with Azure-AsyncOperation header. Subsequent calls to operation @@ -1145,10 +1157,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1187,7 +1200,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_non_resource( - self, sku=None, custom_headers={}, raw=False, **operation_config): + self, sku=None, custom_headers=None, raw=False, **operation_config): """ Long running put request with non resource. @@ -1232,10 +1245,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1269,7 +1283,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_non_resource( - self, sku=None, custom_headers={}, raw=False, **operation_config): + self, sku=None, custom_headers=None, raw=False, **operation_config): """ Long running put request with non resource. @@ -1314,10 +1328,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1351,7 +1366,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_sub_resource( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request with sub resource. @@ -1397,10 +1412,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1434,7 +1450,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_sub_resource( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request with sub resource. @@ -1480,10 +1496,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1517,7 +1534,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_provisioning202_accepted200_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Accepted’. @@ -1556,10 +1573,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1605,7 +1623,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_provisioning202_deleting_failed200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1644,10 +1662,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1693,7 +1712,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_provisioning202_deletingcanceled200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1732,10 +1751,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1781,7 +1801,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete204_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete succeeds and returns right away @@ -1816,10 +1836,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1846,7 +1867,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete202_retry200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a ‘200’ @@ -1884,10 +1905,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1927,7 +1949,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete202_no_retry204( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a ‘200’ @@ -1965,10 +1987,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2008,7 +2031,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_no_header_in_retry( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a location header in the initial request. Subsequent calls to operation status do not contain @@ -2045,10 +2068,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2078,7 +2102,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_no_header_in_retry( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns an Azure-AsyncOperation header in the initial request. Subsequent calls to operation status @@ -2115,10 +2139,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2148,7 +2173,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_retry_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -2185,10 +2210,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2220,7 +2246,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_no_retry_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -2257,10 +2283,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2292,7 +2319,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_retry_failed( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -2329,10 +2356,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2364,7 +2392,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_retrycanceled( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -2401,10 +2429,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2436,7 +2465,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post200_with_payload( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with 'Location' header. Poll returns a 200 with a response @@ -2474,10 +2503,11 @@ def long_running_send(): request = self._client.post(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2513,7 +2543,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_retry200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with 'Location' and 'Retry-After' headers, Polls return a @@ -2560,10 +2590,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2594,7 +2625,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_no_retry204( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with 'Location' header, 204 with noresponse body after @@ -2642,10 +2673,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2685,7 +2717,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -2734,10 +2766,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2778,7 +2811,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_no_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -2827,10 +2860,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2871,7 +2905,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_retry_failed( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -2919,10 +2953,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2954,7 +2989,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_retrycanceled( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -3002,10 +3037,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lro_retrys_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lro_retrys_operations.py index 786c3c3bf6d7d..07307061509af 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lro_retrys_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lro_retrys_operations.py @@ -35,7 +35,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def put201_creating_succeeded200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains @@ -84,10 +84,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -123,7 +124,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains @@ -172,10 +173,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -216,7 +218,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_provisioning202_accepted200_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains @@ -255,10 +257,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -304,7 +307,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete202_retry200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns @@ -341,10 +344,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -375,7 +379,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_relative_retry_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the @@ -412,10 +416,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -447,7 +452,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_retry200( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 500, then a 202 to the initial request, with 'Location' and 'Retry-After' headers, Polls @@ -494,10 +499,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -528,7 +534,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_relative_retry_succeeded( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains @@ -576,10 +582,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lrosa_ds_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lrosa_ds_operations.py index a211b6975e70d..335678d8e547b 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lrosa_ds_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Lro/autorestlongrunningoperationtestservice/operations/lrosa_ds_operations.py @@ -35,7 +35,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def put_non_retry400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 400 to the initial request @@ -81,10 +81,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -120,7 +121,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_non_retry201_creating400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and 201 response code @@ -167,10 +168,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -206,7 +208,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_non_retry201_creating400_invalid_json( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and 201 response code @@ -253,10 +255,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -292,7 +295,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the endpoint indicated in the @@ -340,10 +343,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -384,7 +388,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_non_retry400( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 400 with an error body @@ -419,10 +423,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -453,7 +458,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete202_non_retry400( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 with a location header @@ -489,10 +494,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -523,7 +529,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_relative_retry400( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -560,10 +566,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -595,7 +602,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_non_retry400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 400 with no error body @@ -640,10 +647,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -674,7 +682,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_non_retry400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 with a location header @@ -719,10 +727,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -753,7 +762,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_relative_retry400( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request Poll the endpoint indicated in the Azure-AsyncOperation @@ -800,10 +809,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -835,7 +845,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_error201_no_provisioning_state_payload( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 201 to the initial request with no payload @@ -882,10 +892,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -921,7 +932,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry_no_status( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -970,10 +981,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1014,7 +1026,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry_no_status_payload( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1063,10 +1075,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1107,7 +1120,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete204_succeeded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 204 to the initial request, indicating success. @@ -1143,10 +1156,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1173,7 +1187,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_relative_retry_no_status( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -1210,10 +1224,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1245,7 +1260,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_no_location( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, without a location header. @@ -1291,10 +1306,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1325,7 +1341,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_relative_retry_no_payload( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1373,10 +1389,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1408,7 +1425,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put200_invalid_json( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that is not a valid json @@ -1455,10 +1472,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1492,7 +1510,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry_invalid_header( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1540,10 +1558,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1584,7 +1603,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def put_async_relative_retry_invalid_json_polling( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -1633,10 +1652,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1677,7 +1697,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete202_retry_invalid_header( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request receing a reponse with an invalid 'Location' and @@ -1714,10 +1734,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1748,7 +1769,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_relative_retry_invalid_header( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. The endpoint indicated in the Azure-AsyncOperation header is @@ -1785,10 +1806,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1820,7 +1842,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete_async_relative_retry_invalid_json_polling( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation @@ -1857,10 +1879,11 @@ def long_running_send(): request = self._client.delete(url, query_parameters) return self._client.send(request, header_parameters, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1892,7 +1915,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post202_retry_invalid_header( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with invalid 'Location' and 'Retry-After' headers. @@ -1938,10 +1961,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -1972,7 +1996,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_relative_retry_invalid_header( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -2019,10 +2043,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -2054,7 +2079,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def post_async_relative_retry_invalid_json_polling( - self, product=None, custom_headers={}, raw=False, **operation_config): + self, product=None, custom_headers=None, raw=False, **operation_config): """ Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. @@ -2102,10 +2127,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/__init__.py index 40efea1e6c76f..68708b4282ef4 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_paging_test_service import AutoRestPagingTestService, AutoRestPagingTestServiceConfiguration +from .auto_rest_paging_test_service import AutoRestPagingTestService from .version import VERSION -__all__ = [ - 'AutoRestPagingTestService', - 'AutoRestPagingTestServiceConfiguration' -] +__all__ = ['AutoRestPagingTestService'] __version__ = VERSION 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 e3cf9310642ed..bf82da336e98c 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 @@ -63,21 +63,38 @@ def __init__( class AutoRestPagingTestService(object): """Long-running Operation for AutoRest - :param config: Configuration for client. - :type config: AutoRestPagingTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestPagingTestServiceConfiguration :ivar paging: Paging operations :vartype paging: .operations.PagingOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): - self._client = ServiceClient(config.credentials, config) + self.config = AutoRestPagingTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.paging = PagingOperations( self._client, self.config, self._serialize, self._deserialize) 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 15ba71465cac8..4fcaf367d51bc 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_options.py @@ -14,7 +14,7 @@ class PagingGetMultiplePagesOptions(Model): """ - Additional parameters for the Paging_getMultiplePages operation. + Additional parameters for one or more operations :param maxresults: Sets the maximum number of items to return in the response. diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py index 23e7a887f274c..48ed388233daf 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/models/paging_get_multiple_pages_with_offset_options.py @@ -14,7 +14,7 @@ class PagingGetMultiplePagesWithOffsetOptions(Model): """ - Additional parameters for the Paging_getMultiplePagesWithOffset operation. + Additional parameters for one or more operations :param maxresults: Sets the maximum number of items to return in the response. diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py index a09052357a8f6..d43a7e29ced36 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/Paging/autorestpagingtestservice/operations/paging_operations.py @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_single_pages( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that finishes on the first call without a nextlink @@ -92,7 +92,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages( - self, client_request_id=None, paging_get_multiple_pages_options=None, custom_headers={}, raw=False, **operation_config): + self, client_request_id=None, paging_get_multiple_pages_options=None, custom_headers=None, raw=False, **operation_config): """ A paging operation that includes a nextLink that has 10 pages @@ -170,7 +170,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages_with_offset( - self, paging_get_multiple_pages_with_offset_options, client_request_id=None, custom_headers={}, raw=False, **operation_config): + self, paging_get_multiple_pages_with_offset_options, client_request_id=None, custom_headers=None, raw=False, **operation_config): """ A paging operation that includes a nextLink that has 10 pages @@ -255,7 +255,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages_retry_first( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that fails on the first call with 500 and then retries and then get a response including a nextLink that has 10 pages @@ -314,7 +314,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages_retry_second( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails first with 500. The client should retry and @@ -374,7 +374,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_single_pages_failure( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that receives a 400 on the first call @@ -432,7 +432,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages_failure( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that receives a 400 on the second call @@ -490,7 +490,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def get_multiple_pages_failure_uri( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ A paging operation that receives an invalid nextLink diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/__init__.py index 928015217d6cc..0854715e0c106 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .storage_management_client import StorageManagementClient, StorageManagementClientConfiguration +from .storage_management_client import StorageManagementClient from .version import VERSION -__all__ = [ - 'StorageManagementClient', - 'StorageManagementClientConfiguration' -] +__all__ = ['StorageManagementClient'] __version__ = VERSION 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 cc1c87848bdf4..dc3874fdaac0e 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 @@ -23,7 +23,8 @@ class CheckNameAvailabilityResult(Model): :param reason: Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. Possible values include: 'AccountNameInvalid', 'AlreadyExists' - :type reason: str + :type reason: str or :class:`Reason + ` :param message: Gets an error message explaining the Reason value in more detail. :type message: str diff --git a/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 bff1707d78076..8ed5eace271c2 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 @@ -32,11 +32,13 @@ class StorageAccount(Resource): :param provisioning_state: Gets the status of the storage account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded' - :type provisioning_state: str + :type provisioning_state: str or :class:`ProvisioningState + ` :param account_type: Gets the type of the storage account. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` :param primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue or table object.Note that StandardZRS and PremiumLRS accounts only return the blob endpoint. @@ -48,7 +50,8 @@ class StorageAccount(Resource): :param status_of_primary: Gets the status indicating whether the primary location of the storage account is available or unavailable. Possible values include: 'Available', 'Unavailable' - :type status_of_primary: str + :type status_of_primary: str or :class:`AccountStatus + ` :param last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if there has never @@ -63,7 +66,8 @@ class StorageAccount(Resource): secondary location of the storage account is available or unavailable. Only available if the accountType is StandardGRS or StandardRAGRS. Possible values include: 'Available', 'Unavailable' - :type status_of_secondary: str + :type status_of_secondary: str or :class:`AccountStatus + ` :param creation_time: Gets the creation date and time of the storage account in UTC. :type creation_time: datetime diff --git a/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 31535a2dc8c20..33c7e0b3d7bc1 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 @@ -32,7 +32,8 @@ class StorageAccountCreateParameters(Resource): :param account_type: Gets or sets the account type. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` """ _validation = { diff --git a/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 7fe2da5d56729..7a1da3a0e5757 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 @@ -16,7 +16,8 @@ class StorageAccountRegenerateKeyParameters(Model): """StorageAccountRegenerateKeyParameters :param key_name: Possible values include: 'key1', 'key2' - :type key_name: str + :type key_name: str or :class:`KeyName + ` """ _attribute_map = { diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/models/storage_account_update_parameters.py index e60b187d613bd..f858c85e39aaf 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 @@ -34,7 +34,8 @@ class StorageAccountUpdateParameters(Resource): other account types cannot be changed to StandardZRS or PremiumLRS. Possible values include: 'Standard_LRS', 'Standard_ZRS', 'Standard_GRS', 'Standard_RAGRS', 'Premium_LRS' - :type account_type: str + :type account_type: str or :class:`AccountType + ` :param custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty diff --git a/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 53d96b70adf16..9b3983b234a51 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 @@ -19,7 +19,8 @@ class Usage(Model): :param unit: Gets the unit of measurement. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' - :type unit: str + :type unit: str or :class:`UsageUnit + ` :param current_value: Gets the current count of the allocated resources in the subscription. :type current_value: int diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py index 2250ab10c1468..d2583af6ef3d7 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py @@ -35,7 +35,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def check_name_availability( - self, account_name, custom_headers={}, raw=False, **operation_config): + self, account_name, custom_headers=None, raw=False, **operation_config): """ Checks that account name is valid and is not in use. @@ -102,7 +102,7 @@ def check_name_availability( return deserialized def create( - self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): """ Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and @@ -164,10 +164,11 @@ def long_running_send(): return self._client.send( request, header_parameters, body_content, **operation_config) - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @@ -201,7 +202,7 @@ def get_long_running_output(response): get_long_running_status, long_running_operation_timeout) def delete( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Deletes a storage account in Microsoft Azure. @@ -259,7 +260,7 @@ def delete( return client_raw_response def get_properties( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The @@ -327,7 +328,7 @@ def get_properties( return deserialized def update( - self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, parameters, custom_headers=None, raw=False, **operation_config): """ Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added @@ -410,7 +411,7 @@ def update( return deserialized def list_keys( - self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): """ Lists the access keys for the specified storage account. @@ -472,7 +473,7 @@ def list_keys( return deserialized def list( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for @@ -537,7 +538,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def list_by_resource_group( - self, resource_group_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, custom_headers=None, raw=False, **operation_config): """ Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys @@ -606,7 +607,7 @@ def internal_paging(next_link=None, raw=False): return deserialized def regenerate_key( - self, resource_group_name, account_name, key_name=None, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, account_name, key_name=None, custom_headers=None, raw=False, **operation_config): """ Regenerates the access keys for the specified storage account. @@ -619,7 +620,8 @@ def regenerate_key( only. :type account_name: str :param key_name: Possible values include: 'key1', 'key2' - :type key_name: str + :type key_name: str or :class:`KeyName + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/usage_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/usage_operations.py index 80b0c0aca8a9a..c4401f53ec531 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/usage_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/usage_operations.py @@ -34,7 +34,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def list( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Gets the current usage count and the limit for the resources under the subscription. diff --git a/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 1334ec94142ec..384c65cdaab44 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 @@ -78,24 +78,47 @@ def __init__( class StorageManagementClient(object): """StorageManagementClient - :param config: Configuration for client. - :type config: StorageManagementClientConfiguration + :ivar config: Configuration for client. + :vartype config: StorageManagementClientConfiguration :ivar storage_accounts: StorageAccounts operations :vartype storage_accounts: .operations.StorageAccountsOperations :ivar usage: Usage operations :vartype usage: .operations.UsageOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Gets subscription credentials which uniquely + identify Microsoft Azure subscription. The subscription ID forms part of + the URI for every service call. + :type subscription_id: str + :param api_version: Client Api Version. + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + 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): - self._client = ServiceClient(config.credentials, config) + self.config = StorageManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.storage_accounts = StorageAccountsOperations( self._client, self.config, self._serialize, self._deserialize) self.usage = UsageOperations( diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/__init__.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/__init__.py index 1841a70993a8f..fb1c1642d2859 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/__init__.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .microsoft_azure_test_url import MicrosoftAzureTestUrl, MicrosoftAzureTestUrlConfiguration +from .microsoft_azure_test_url import MicrosoftAzureTestUrl from .version import VERSION -__all__ = [ - 'MicrosoftAzureTestUrl', - 'MicrosoftAzureTestUrlConfiguration' -] +__all__ = ['MicrosoftAzureTestUrl'] __version__ = VERSION 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 d16f3f25706a6..7a5752c26569d 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 @@ -75,21 +75,42 @@ def __init__( class MicrosoftAzureTestUrl(object): """Some cool documentation. - :param config: Configuration for client. - :type config: MicrosoftAzureTestUrlConfiguration + :ivar config: Configuration for client. + :vartype config: MicrosoftAzureTestUrlConfiguration :ivar group: Group operations :vartype group: .operations.GroupOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Subscription Id. + :type subscription_id: str + :param api_version: API Version with value '2014-04-01-preview'. + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + 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): - self._client = ServiceClient(config.credentials, config) + self.config = MicrosoftAzureTestUrlConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.group = GroupOperations( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/operations/group_operations.py b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/operations/group_operations.py index 07c0bf0c8cbcf..0ed768dc0f15e 100644 --- a/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/operations/group_operations.py +++ b/AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/microsoftazuretesturl/operations/group_operations.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_sample_resource_group( - self, resource_group_name, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, custom_headers=None, raw=False, **operation_config): """ Provides a resouce group with name 'testgroup101' and location 'West US'. diff --git a/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml b/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml index 78533cd451225..ed54f678d5314 100644 --- a/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml +++ b/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml @@ -94,10 +94,11 @@ else @:return self._client.send(request, header_parameters, **operation_config) } @EmptyLine - def get_long_running_status(status_link, headers={}): + def get_long_running_status(status_link, headers=None): @EmptyLine request = self._client.get(status_link) - request.headers.update(headers) + if headers: + request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) @EmptyLine diff --git a/AutoRest/Generators/Python/Azure.Python/Templates/AzureServiceClientTemplate.cshtml b/AutoRest/Generators/Python/Azure.Python/Templates/AzureServiceClientTemplate.cshtml index 1bd45c95a8d80..713d36e132428 100644 --- a/AutoRest/Generators/Python/Azure.Python/Templates/AzureServiceClientTemplate.cshtml +++ b/AutoRest/Generators/Python/Azure.Python/Templates/AzureServiceClientTemplate.cshtml @@ -92,23 +92,37 @@ else @EmptyLine class @(Model.Name)(object): """@Model.ServiceDocument -@EmptyLine - :param config: Configuration for client. - :type config: @(Model.Name)Configuration + @EmptyLine + :ivar config: Configuration for client. + :vartype config: @(Model.Name)Configuration @if (Model.MethodGroupModels.Any()) { -@EmptyLine - foreach (var methodGroup in Model.MethodGroupModels) - { + @EmptyLine + foreach (var methodGroup in Model.MethodGroupModels) + { @: :ivar @(methodGroup.MethodGroupName.ToPythonCase()): @(methodGroup.MethodGroupName) operations @: :vartype @(methodGroup.MethodGroupName.ToPythonCase()): .operations.@(methodGroup.MethodGroupType) - } + } +} +@EmptyLine +@foreach (var property in Model.Properties) +{ +@: @ParameterWrapComment(string.Empty, ServiceClientTemplateModel.GetPropertyDocumentationString(property)) +@: @ParameterWrapComment(string.Empty, ":type " + property.Name + ": " + Model.GetPropertyDocumentationType(property.Type)) } + +@if (!Model.IsCustomBaseUri) +{ +@: :param str base_url: Service URL +} + :param str filepath: Existing config """ @EmptyLine - def __init__(self, config): + def __init__( + self, @(Model.RequiredConstructorParameters)@(Model.IsCustomBaseUri ? "" : "base_url=None, ")filepath=None): @EmptyLine - self._client = ServiceClient(@(Model.Properties.Any(p => p.Type.IsPrimaryType(KnownPrimaryType.Credentials)) ? "config.credentials" : PythonConstants.None), config) + self.config = @(Model.Name)Configuration(@(Model.ConfigConstructorParameters)@(Model.IsCustomBaseUri ? "" : "base_url, ")filepath) + self._client = ServiceClient(@(Model.Properties.Any(p => p.Type.IsPrimaryType(KnownPrimaryType.Credentials)) ? "self.config.credentials" : PythonConstants.None), self.config) @EmptyLine @if (Model.ModelTemplateModels.Any()) { @@ -118,10 +132,9 @@ else { @:client_models = {} } - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) @EmptyLine - self.config = config @foreach (var methodGroup in Model.MethodGroupModels) { @:self.@(methodGroup.MethodGroupName.ToPythonCase()) = @(methodGroup.MethodGroupType)( diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/array_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/array_tests.py index 153b8635ecd79..c919eeb450ebe 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/array_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/array_tests.py @@ -45,20 +45,14 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestswaggerbatarrayservice import ( - AutoRestSwaggerBATArrayService, - AutoRestSwaggerBATArrayServiceConfiguration) - +from autorestswaggerbatarrayservice import AutoRestSwaggerBATArrayService from autorestswaggerbatarrayservice.models import Product class ArrayTests(unittest.TestCase): def test_array(self): - - config = AutoRestSwaggerBATArrayServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestSwaggerBATArrayService(config) + client = AutoRestSwaggerBATArrayService(base_url="http://localhost:3000") self.assertListEqual([], client.array.get_empty()) self.assertIsNone(client.array.get_null()) @@ -214,6 +208,11 @@ def test_array(self): with self.assertRaises(DeserializationError): client.array.get_date_time_invalid_chars() + test_array = ['a string that gets encoded with base64url'.encode(), + 'test string'.encode(), + 'Lorem ipsum'.encode()] + self.assertEqual(client.array.get_base64_url(), test_array) + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/bool_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/bool_tests.py index 6d3ff7c519968..6f90a1638187c 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/bool_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/bool_tests.py @@ -45,19 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestbooltestservice import ( - AutoRestBoolTestService, - AutoRestBoolTestServiceConfiguration) - +from autorestbooltestservice import AutoRestBoolTestService from autorestbooltestservice.models import ErrorException class BoolTests(unittest.TestCase): def test_bool(self): - - config = AutoRestBoolTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestBoolTestService(config) + client = AutoRestBoolTestService(base_url="http://localhost:3000") self.assertTrue(client.bool_model.get_true()) self.assertFalse(client.bool_model.get_false()) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/byte_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/byte_tests.py index f61c067d63248..c792f75fbe77c 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/byte_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/byte_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestswaggerbatbyteservice import ( - AutoRestSwaggerBATByteService, - AutoRestSwaggerBATByteServiceConfiguration) +from autorestswaggerbatbyteservice import AutoRestSwaggerBATByteService class ByteTests(unittest.TestCase): def test_byte(self): - - config = AutoRestSwaggerBATByteServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestSwaggerBATByteService(config) + client = AutoRestSwaggerBATByteService(base_url="http://localhost:3000") test_bytes = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x0FB, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6]) client.byte.put_non_ascii(test_bytes) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/complex_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/complex_tests.py index fa4902659e391..fa065c09c6e6a 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/complex_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/complex_tests.py @@ -45,10 +45,7 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError, SerializationError, ValidationError -from autorestcomplextestservice import ( - AutoRestComplexTestService, - AutoRestComplexTestServiceConfiguration) - +from autorestcomplextestservice import AutoRestComplexTestService from autorestcomplextestservice.models import * class UTC(tzinfo): @@ -65,18 +62,17 @@ def dst(self,dt): class ComplexTests(unittest.TestCase): def test_complex(self): - - config = AutoRestComplexTestServiceConfiguration(base_url="http://localhost:3000",api_version="2015-01-01") - config.log_level = log_level - client = AutoRestComplexTestService(config) + client = AutoRestComplexTestService(base_url="http://localhost:3000",api_version="2015-01-01") # GET basic/valid basic_result = client.basic_operations.get_valid() self.assertEqual(2, basic_result.id) self.assertEqual("abc", basic_result.name); - self.assertEqual(CMYKColors.yellow, basic_result.color); + self.assertEqual(CMYKColors.yellow.value, basic_result.color); # PUT basic/valid + basic_result = Basic(id=2, name='abc', color="Magenta") + client.basic_operations.put_valid(basic_result) basic_result = Basic(id=2, name='abc', color=CMYKColors.magenta) client.basic_operations.put_valid(basic_result) @@ -107,7 +103,7 @@ def test_complex(self): self.assertEqual(2, intResult.field2) # PUT primitive/integer - intRequest = IntWrapper(field1=-1, field2=2) + intRequest = {'field1':-1, 'field2':2} client.primitive.put_int(intRequest) # GET primitive/long @@ -116,7 +112,7 @@ def test_complex(self): self.assertEqual(-999511627788, longResult.field2) # PUT primitive/long - longRequest = LongWrapper(field1=1099511627775, field2=-999511627788) + longRequest = {'field1':1099511627775, 'field2':-999511627788} client.primitive.put_long(longRequest) # GET primitive/float @@ -134,8 +130,8 @@ def test_complex(self): self.assertEqual(-5e-57, doubleResult.field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose) # PUT primitive/double - doubleRequest = DoubleWrapper(field1=3e-100) - doubleRequest.field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose = -5e-57 + doubleRequest = {'field1':3e-100} + doubleRequest['field_56_zeros_after_the_dot_and_negative_zero_before_dot_and_this_is_a_long_field_name_on_purpose'] = -5e-57 client.primitive.put_double(doubleRequest); # GET primitive/bool @@ -275,14 +271,14 @@ def test_complex(self): self.assertEqual("Tomato", inheritanceResult.hates[1].name) # PUT inheritance/valid - request = Siamese( - id=2, - name="Siameeee", - color="green", - breed="persian", - hates=[Dog(id=1, name="Potato", food="tomato"), + request = { + 'id': 2, + 'name': "Siameeee", + 'color': "green", + 'breed': "persian", + 'hates': [Dog(id=1, name="Potato", food="tomato"), Dog(id=-1, name="Tomato", food="french fries")] - ) + } client.inheritance.put_valid(request) """ diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/custom_base_uri_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/custom_base_uri_tests.py index 36d4ba09cf8c7..d1a49930ec386 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/custom_base_uri_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/custom_base_uri_tests.py @@ -39,6 +39,7 @@ tests = realpath(join(cwd, pardir, "Expected", "AcceptanceTests")) sys.path.append(join(tests, "CustomBaseUri")) +sys.path.append(join(tests, "CustomBaseUriMoreOptions")) from msrest.exceptions import ( DeserializationError, @@ -46,30 +47,20 @@ ClientRequestError, ValidationError) -from autorestparameterizedhosttestclient import ( - AutoRestParameterizedHostTestClient, - AutoRestParameterizedHostTestClientConfiguration) - +from autorestparameterizedhosttestclient import AutoRestParameterizedHostTestClient from autorestparameterizedhosttestclient.models import Error, ErrorException +from autorestparameterizedcustomhosttestclient import AutoRestParameterizedCustomHostTestClient class CustomBaseUriTests(unittest.TestCase): def test_custom_base_uri_positive(self): - config = AutoRestParameterizedHostTestClientConfiguration( - "host:3000") - - config.log_level = log_level - client = AutoRestParameterizedHostTestClient(config) + client = AutoRestParameterizedHostTestClient("host:3000") client.paths.get_empty("local") def test_custom_base_uri_negative(self): - config = AutoRestParameterizedHostTestClientConfiguration( - "host:3000") - - config.log_level = log_level - config.retry_policy.retries = 0 - client = AutoRestParameterizedHostTestClient(config) + client = AutoRestParameterizedHostTestClient("host:3000") + client.config.retry_policy.retries = 0 with self.assertRaises(ClientRequestError): client.paths.get_empty("bad") @@ -81,6 +72,10 @@ def test_custom_base_uri_negative(self): with self.assertRaises(ClientRequestError): client.paths.get_empty("local") + def test_custom_base_uri_more_optiopns(self): + client = AutoRestParameterizedCustomHostTestClient("test12", "host.:3000") + client.paths.get_empty("http://lo", "cal", "key1") + if __name__ == '__main__': diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/date_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/date_tests.py index a5ef7791aa801..2b836431aeabe 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/date_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/date_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestdatetestservice import ( - AutoRestDateTestService, - AutoRestDateTestServiceConfiguration) +from autorestdatetestservice import AutoRestDateTestService class DateTests(unittest.TestCase): def test_date(self): - - config = AutoRestDateTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestDateTestService(config) + client = AutoRestDateTestService(base_url="http://localhost:3000") max_date = isodate.parse_date("9999-12-31T23:59:59.999999Z") min_date = isodate.parse_date("0001-01-01T00:00:00Z") diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_rfc_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_rfc_tests.py index 778e2c09585b2..e5c8efe8c3bef 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_rfc_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_rfc_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestrfc1123datetimetestservice import ( - AutoRestRFC1123DateTimeTestService, - AutoRestRFC1123DateTimeTestServiceConfiguration) +from autorestrfc1123datetimetestservice import AutoRestRFC1123DateTimeTestService class DateTimeRfcTests(unittest.TestCase): def test_datetime_rfc(self): - - config = AutoRestRFC1123DateTimeTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestRFC1123DateTimeTestService(config) + client = AutoRestRFC1123DateTimeTestService(base_url="http://localhost:3000") self.assertIsNone(client.datetimerfc1123.get_null()) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_tests.py index 929df927e29b4..2217a3783b47c 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/datetime_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError, SerializationError -from autorestdatetimetestservice import ( - AutoRestDateTimeTestService, - AutoRestDateTimeTestServiceConfiguration) +from autorestdatetimetestservice import AutoRestDateTimeTestService class DatetimeTests(unittest.TestCase): def test_datetime(self): - - config = AutoRestDateTimeTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestDateTimeTestService(config) + client = AutoRestDateTimeTestService(base_url="http://localhost:3000") max_date = isodate.parse_datetime("9999-12-31T23:59:59.999999Z") min_date = isodate.parse_datetime("0001-01-01T00:00:00Z") diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/dictionary_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/dictionary_tests.py index 39ec8b5000c8c..477591ffa9f4f 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/dictionary_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/dictionary_tests.py @@ -42,7 +42,7 @@ from msrest.exceptions import DeserializationError -from autorestswaggerbatdictionaryservice import AutoRestSwaggerBATdictionaryService, AutoRestSwaggerBATdictionaryServiceConfiguration +from autorestswaggerbatdictionaryservice import AutoRestSwaggerBATdictionaryService from autorestswaggerbatdictionaryservice.models import Widget, ErrorException @@ -50,10 +50,7 @@ class DictionaryTests(unittest.TestCase): @classmethod def setUpClass(cls): - - config = AutoRestSwaggerBATdictionaryServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - cls.client = AutoRestSwaggerBATdictionaryService(config) + cls.client = AutoRestSwaggerBATdictionaryService(base_url="http://localhost:3000") return super(DictionaryTests, cls).setUpClass() def test_dictionary_primitive_types(self): @@ -185,6 +182,11 @@ def test_dictionary_primitive_types(self): bytes_result = self.client.dictionary.get_byte_invalid_null() self.assertEqual(bytes_null, bytes_result) + test_dict = {'0': 'a string that gets encoded with base64url'.encode(), + '1': 'test string'.encode(), + '2': 'Lorem ipsum'.encode()} + self.assertEqual(self.client.dictionary.get_base64_url(), test_dict) + def test_basic_dictionary_parsing(self): self.assertEqual({}, self.client.dictionary.get_empty()) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/duration_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/duration_tests.py index 38367dd9c9361..8ec68c0dd1972 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/duration_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/duration_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestdurationtestservice import ( - AutoRestDurationTestService, - AutoRestDurationTestServiceConfiguration) +from autorestdurationtestservice import AutoRestDurationTestService class DurationTests(unittest.TestCase): def test_duration(self): - - config = AutoRestDurationTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestDurationTestService(config) + client = AutoRestDurationTestService(base_url="http://localhost:3000") self.assertIsNone(client.duration.get_null()) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py index 900265a4ed1fe..903d69f3dba2e 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/file_tests.py @@ -44,17 +44,15 @@ from msrest.exceptions import DeserializationError -from autorestswaggerbatfileservice import AutoRestSwaggerBATFileService, AutoRestSwaggerBATFileServiceConfiguration +from autorestswaggerbatfileservice import AutoRestSwaggerBATFileService from autorestswaggerbatfileservice.models import ErrorException class FileTests(unittest.TestCase): def test_files(self): - - config = AutoRestSwaggerBATFileServiceConfiguration(base_url="http://localhost:3000") - config.connection.data_block_size = 1000 - client = AutoRestSwaggerBATFileService(config) + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 1000 def test_callback(data, response, progress=[0]): self.assertTrue(len(data) > 0) @@ -83,7 +81,7 @@ def test_callback(data, response, progress=[0]): sample_data = hash(data.read()) self.assertEqual(sample_data, hash(file_handle.getvalue())) - config.connection.data_block_size = 4096 + client.config.connection.data_block_size = 4096 file_length = 0 with io.BytesIO() as file_handle: stream = client.files.get_empty_file(callback=test_callback) @@ -116,8 +114,7 @@ def test_callback(data, response, progress=[0]): progress[0] += len(data) print("Downloading... {}%".format(int(progress[0]*100/total))) - config = AutoRestSwaggerBATFileServiceConfiguration(base_url="http://localhost:3000") - client = AutoRestSwaggerBATFileService(config) + client = AutoRestSwaggerBATFileService(base_url="http://localhost:3000") file_length = 0 with io.BytesIO() as file_handle: 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 ea1ed1a726f9e..b1fa2f0cbec90 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/form_data_tests.py @@ -43,7 +43,7 @@ from msrest.exceptions import DeserializationError -from autorestswaggerbatformdataservice import AutoRestSwaggerBATFormDataService, AutoRestSwaggerBATFormDataServiceConfiguration +from autorestswaggerbatformdataservice import AutoRestSwaggerBATFormDataService class FormDataTests(unittest.TestCase): @@ -63,10 +63,8 @@ def test_callback(data, response, progress = [0]): print("Progress... {}%".format(int(progress[0]*100/total))) self.assertIsNotNone(response) - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.connection.data_block_size = 2 - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 2 test_string = "Upload file test case" test_bytes = bytearray(test_string, encoding='utf-8') @@ -86,10 +84,8 @@ def test_callback(data, response, progress = [0]): print("Progress... {}%".format(int(progress[0]*100/total))) self.assertIsNotNone(response) - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.connection.data_block_size = 2 - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 2 test_string = "Upload file test case" test_bytes = bytearray(test_string, encoding='utf-8') @@ -109,10 +105,8 @@ def test_callback(data, response, progress = [0]): print("Progress... {}%".format(int(progress[0]*100/total))) self.assertIsNotNone(response) - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.connection.data_block_size = 2 - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 2 name = os.path.basename(self.dummy_file) result = io.BytesIO() @@ -131,10 +125,8 @@ def test_callback(data, response, progress = [0]): print("Progress... {}%".format(int(progress[0]*100/total))) self.assertIsNotNone(response) - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.connection.data_block_size = 2 - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 2 name = os.path.basename(self.dummy_file) result = io.BytesIO() @@ -158,10 +150,8 @@ def test_callback(data, response, progress = [0]): else: print("Uploading... {}%".format(int(progress[0]*100/total))) - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.connection.data_block_size = 2 - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") + client.config.connection.data_block_size = 2 result = io.BytesIO() with io.BytesIO(test_bytes) as stream_data: @@ -178,10 +168,7 @@ def test_callback(data, response, progress = [0]): self.assertEqual(result.getvalue().decode(), "Test file") def test_file_body_upload_raw(self): - - config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestSwaggerBATFormDataService(config) + client = AutoRestSwaggerBATFormDataService(base_url="http://localhost:3000") test_string = "Upload file test case" test_bytes = bytearray(test_string, encoding='utf-8') diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/header_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/header_tests.py index 0a77d8dc6efeb..e6649e6378f07 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/header_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/header_tests.py @@ -45,17 +45,14 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestswaggerbatheaderservice import AutoRestSwaggerBATHeaderService, AutoRestSwaggerBATHeaderServiceConfiguration +from autorestswaggerbatheaderservice import AutoRestSwaggerBATHeaderService from autorestswaggerbatheaderservice.models.auto_rest_swagger_bat_header_service_enums import GreyscaleColors class HeaderTests(unittest.TestCase): def test_headers(self): - - config = AutoRestSwaggerBATHeaderServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestSwaggerBATHeaderService(config) + client = AutoRestSwaggerBATHeaderService(base_url="http://localhost:3000") client.header.param_integer("positive", 1) client.header.param_integer("negative", -2) @@ -110,6 +107,7 @@ def test_headers(self): self.assertEqual("", raw.headers.get("value")) client.header.param_enum("valid", GreyscaleColors.grey) + client.header.param_enum("valid", 'GREY') client.header.param_enum("null", None) raw = client.header.response_enum("valid", raw=True) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/http_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/http_tests.py index c562609e4307d..3db36e576af8e 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/http_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/http_tests.py @@ -44,10 +44,7 @@ from msrest.exceptions import DeserializationError, HttpOperationError -from autoresthttpinfrastructuretestservice import ( - AutoRestHttpInfrastructureTestService, - AutoRestHttpInfrastructureTestServiceConfiguration) - +from autoresthttpinfrastructuretestservice import AutoRestHttpInfrastructureTestService from autoresthttpinfrastructuretestservice.models import ( A, B, C, D, ErrorException) @@ -55,10 +52,8 @@ class HttpTests(unittest.TestCase): def setUp(self): - config = AutoRestHttpInfrastructureTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - config.retry_policy.retries = 3 - self.client = AutoRestHttpInfrastructureTestService(config) + self.client = AutoRestHttpInfrastructureTestService(base_url="http://localhost:3000") + self.client.config.retry_policy.retries = 3 self.client._client._adapter.add_hook("request", self.client._client._adapter._test_pipeline) return super(HttpTests, self).setUp() diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/integer_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/integer_tests.py index dec0ba58003d6..d1b000739c9d7 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/integer_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/integer_tests.py @@ -30,7 +30,7 @@ import isodate import tempfile import json -from datetime import date, datetime, timedelta +from datetime import date, datetime, timedelta, tzinfo import os from os.path import dirname, pardir, join, realpath, sep, pardir @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestintegertestservice import ( - AutoRestIntegerTestService, - AutoRestIntegerTestServiceConfiguration) +from autorestintegertestservice import AutoRestIntegerTestService class IntegerTests(unittest.TestCase): def test_integer(self): - - config = AutoRestIntegerTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestIntegerTestService(config) + client = AutoRestIntegerTestService(base_url="http://localhost:3000") client.int_model.put_max32(2147483647) # sys.maxint client.int_model.put_min32(-2147483648) @@ -74,6 +69,14 @@ def test_integer(self): #client.int_model.get_underflow_int32() #client.int_model.get_underflow_int64() + unix_date = datetime(year=2016, month=4, day=13) + client.int_model.put_unix_time_date(unix_date) + self.assertEqual(unix_date.utctimetuple(), client.int_model.get_unix_time().utctimetuple()) + self.assertIsNone(client.int_model.get_null_unix_time()) + + with self.assertRaises(DeserializationError): + client.int_model.get_invalid_unix_time() + if __name__ == '__main__': unittest.main() \ No newline at end of file diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/model_flattening_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/model_flattening_tests.py index f15c8d90a2c92..7a80a4f152e8c 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/model_flattening_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/model_flattening_tests.py @@ -45,10 +45,7 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestresourceflatteningtestservice import ( - AutoRestResourceFlatteningTestService, - AutoRestResourceFlatteningTestServiceConfiguration) - +from autorestresourceflatteningtestservice import AutoRestResourceFlatteningTestService from autorestresourceflatteningtestservice.models import ( FlattenedProduct, ErrorException, @@ -59,10 +56,7 @@ class ModelFlatteningTests(unittest.TestCase): def setUp(self): - config = AutoRestResourceFlatteningTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - self.client = AutoRestResourceFlatteningTestService(config) - + self.client = AutoRestResourceFlatteningTestService(base_url="http://localhost:3000") return super(ModelFlatteningTests, self).setUp() def test_flattening_array(self): @@ -90,11 +84,11 @@ def test_flattening_array(self): self.assertEqual("Resource3", result[2].name) resourceArray = [ - FlattenedProduct( - location = "West US", - tags = {"tag1":"value1", "tag2":"value3"}), - FlattenedProduct( - location = "Building 44")] + { + 'location': "West US", + 'tags': {"tag1":"value1", "tag2":"value3"}}, + { + 'location': "Building 44"}] self.client.put_array(resourceArray) @@ -123,15 +117,15 @@ def test_flattening_dictionary(self): self.assertEqual("Resource3", resultDictionary["Product3"].name) resourceDictionary = { - "Resource1": FlattenedProduct( - location = "West US", - tags = {"tag1":"value1", "tag2":"value3"}, - pname = "Product1", - flattened_product_type = "Flat"), - "Resource2": FlattenedProduct( - location = "Building 44", - pname = "Product2", - flattened_product_type = "Flat")} + "Resource1": { + 'location': "West US", + 'tags': {"tag1":"value1", "tag2":"value3"}, + 'pname': "Product1", + 'flattened_product_type': "Flat"}, + "Resource2": { + 'location': "Building 44", + 'pname': "Product2", + 'flattened_product_type': "Flat"}} self.client.put_dictionary(resourceDictionary) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/number_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/number_tests.py index a38a02f81f0db..c3cc2bdea971b 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/number_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/number_tests.py @@ -45,18 +45,13 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError -from autorestnumbertestservice import ( - AutoRestNumberTestService, - AutoRestNumberTestServiceConfiguration) +from autorestnumbertestservice import AutoRestNumberTestService class NumberTests(unittest.TestCase): def test_numbers(self): - - config = AutoRestNumberTestServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestNumberTestService(config) + client = AutoRestNumberTestService(base_url="http://localhost:3000") client.number.put_big_float(3.402823e+20) client.number.put_small_float(3.402823e-20) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/required_optional_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/required_optional_tests.py index b8da49a9412dd..28c881cf48528 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/required_optional_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/required_optional_tests.py @@ -42,10 +42,7 @@ from msrest.exceptions import DeserializationError, SerializationError, ValidationError -from autorestrequiredoptionaltestservice import ( - AutoRestRequiredOptionalTestService, - AutoRestRequiredOptionalTestServiceConfiguration) - +from autorestrequiredoptionaltestservice import AutoRestRequiredOptionalTestService from autorestrequiredoptionaltestservice.models import StringWrapper, ArrayWrapper, ClassWrapper @@ -53,14 +50,10 @@ class RequiredOptionalTests(unittest.TestCase): @classmethod def setUpClass(cls): - - config = AutoRestRequiredOptionalTestServiceConfiguration( + cls.client = AutoRestRequiredOptionalTestService( "required_path", "required_query", base_url="http://localhost:3000") - - config.log_level = log_level - cls.client = AutoRestRequiredOptionalTestService(config) return super(RequiredOptionalTests, cls).setUpClass() def test_required_optional(self): diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/string_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/string_tests.py index 003aebc3a9168..4236d75b66ed3 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/string_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/string_tests.py @@ -44,21 +44,15 @@ sys.path.append(join(tests, "BodyString")) from msrest.serialization import Deserializer -from msrest.exceptions import DeserializationError - -from autorestswaggerbatservice import ( - AutoRestSwaggerBATService, - AutoRestSwaggerBATServiceConfiguration) +from msrest.exceptions import DeserializationError, SerializationError +from autorestswaggerbatservice import AutoRestSwaggerBATService from autorestswaggerbatservice.models.auto_rest_swagger_bat_service_enums import * class StringTests(unittest.TestCase): def test_string(self): - - config = AutoRestSwaggerBATServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestSwaggerBATService(config) + client = AutoRestSwaggerBATService(base_url="http://localhost:3000") self.assertIsNone(client.string.get_null()) client.string.put_null(None) @@ -108,7 +102,15 @@ def test_string(self): self.assertIsNone(client.string.get_not_provided()) self.assertEqual(Colors.redcolor, client.enum.get_not_expandable()) + client.enum.put_not_expandable('red color') client.enum.put_not_expandable(Colors.redcolor) + with self.assertRaises(SerializationError): + client.enum.put_not_expandable('not a colour') + + self.assertEqual(client.string.get_base64_encoded(), 'a string that gets encoded with base64'.encode()) + self.assertEqual(client.string.get_base64_url_encoded(), 'a string that gets encoded with base64url'.encode()) + self.assertIsNone(client.string.get_null_base64_url_encoded()) + client.string.put_base64_url_encoded('a string that gets encoded with base64url'.encode()) if __name__ == '__main__': diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py index 3204669e8568c..04e4c94e359a4 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/url_tests.py @@ -43,7 +43,7 @@ from msrest.exceptions import DeserializationError, ValidationError -from autoresturltestservice import AutoRestUrlTestService, AutoRestUrlTestServiceConfiguration +from autoresturltestservice import AutoRestUrlTestService from autoresturltestservice.models.auto_rest_url_test_service_enums import UriColor @@ -51,10 +51,7 @@ class UrlTests(unittest.TestCase): @classmethod def setUpClass(cls): - - config = AutoRestUrlTestServiceConfiguration('', base_url="http://localhost:3000") - config.log_level = log_level - cls.client = AutoRestUrlTestService(config) + cls.client = AutoRestUrlTestService('', base_url="http://localhost:3000") return super(UrlTests, cls).setUpClass() def test_url_path(self): @@ -77,6 +74,7 @@ def test_url_path(self): self.client.paths.date_time_valid(isodate.parse_datetime("2012-01-01T01:01:01Z")) self.client.paths.date_valid(isodate.parse_date("2012-01-01")) + self.client.paths.unix_time_url(datetime(year=2016, month=4, day=13)) self.client.paths.double_decimal_negative(-9999999.999) self.client.paths.double_decimal_positive(9999999.999) @@ -103,6 +101,8 @@ def test_url_path(self): with self.assertRaises(ValidationError): self.client.paths.enum_null(None) + self.client.paths.base64_url("lorem".encode()) + def test_url_query(self): self.client.config.global_string_path = '' diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/validation_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/validation_tests.py index 7e1ba54e0556e..2d5eb21d928e7 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/validation_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/validation_tests.py @@ -45,9 +45,7 @@ from msrest.serialization import Deserializer from msrest.exceptions import DeserializationError, ValidationError -from autorestvalidationtest import ( - AutoRestValidationTest, - AutoRestValidationTestConfiguration) +from autorestvalidationtest import AutoRestValidationTest from autorestvalidationtest.models import ( Product, ConstantProduct, @@ -57,13 +55,10 @@ class ValidationTests(unittest.TestCase): def test_constant_values(self): - - config = AutoRestValidationTestConfiguration( + client = AutoRestValidationTest( "abc123", "12-34-5678", base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestValidationTest(config) client.get_with_constant_in_path() @@ -72,13 +67,10 @@ def test_constant_values(self): self.assertIsNotNone(product) def test_validation(self): - - config = AutoRestValidationTestConfiguration( + client = AutoRestValidationTest( "abc123", "12-34-5678", base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestValidationTest(config) try: client.validation_of_method_parameters("1", 100) @@ -138,12 +130,10 @@ def test_validation(self): self.assertEqual(err.rule, "max_items") self.assertEqual(err.target, "display_names") - config2 = AutoRestValidationTestConfiguration( + client2 = AutoRestValidationTest( "abc123", "abc", base_url="http://localhost:3000") - config2.log_level = log_level - client2 = AutoRestValidationTest(config2) try: client2.validation_of_method_parameters("123", 150) diff --git a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py index 2afd6aa9c3c70..0accfbac70edc 100644 --- a/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py +++ b/AutoRest/Generators/Python/Python.Tests/AcceptanceTests/zzz_tests.py @@ -41,17 +41,13 @@ sys.path.append(join(tests, "Report")) -from autorestreportservice import ( - AutoRestReportService, - AutoRestReportServiceConfiguration) +from autorestreportservice import AutoRestReportService class AcceptanceTests(unittest.TestCase): - def test_ensure_coverage(self): - config = AutoRestReportServiceConfiguration(base_url="http://localhost:3000") - config.log_level = log_level - client = AutoRestReportService(config) + def test_ensure_coverage(self): + client = AutoRestReportService(base_url="http://localhost:3000") report = client.get_report() # Add tests that wont be supported due to the nature of Python here diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/__init__.py index aaf980709effe..1aef76714e640 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_array_service import AutoRestSwaggerBATArrayService, AutoRestSwaggerBATArrayServiceConfiguration +from .auto_rest_swagger_bat_array_service import AutoRestSwaggerBATArrayService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATArrayService', - 'AutoRestSwaggerBATArrayServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATArrayService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/auto_rest_swagger_bat_array_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/auto_rest_swagger_bat_array_service.py index 8ebdaa19bfa3b..75d5ea27f0cf5 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/auto_rest_swagger_bat_array_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/auto_rest_swagger_bat_array_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATArrayService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATArrayServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATArrayServiceConfiguration :ivar array: Array operations :vartype array: .operations.Array + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATArrayServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.array = Array( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/operations/array.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/operations/array.py index 1d437ec67f879..abed9ea1af30e 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/operations/array.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyArray/autorestswaggerbatarrayservice/operations/array.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null array value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid array [1, 2, 3 @@ -120,7 +120,7 @@ def get_invalid( return deserialized def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty array value [] @@ -164,7 +164,7 @@ def get_empty( return deserialized def put_empty( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value empty [] @@ -207,7 +207,7 @@ def put_empty( return client_raw_response def get_boolean_tfft( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean array value [true, false, false, true] @@ -251,7 +251,7 @@ def get_boolean_tfft( return deserialized def put_boolean_tfft( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value empty [true, false, false, true] @@ -294,7 +294,7 @@ def put_boolean_tfft( return client_raw_response def get_boolean_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean array value [true, null, false] @@ -338,7 +338,7 @@ def get_boolean_invalid_null( return deserialized def get_boolean_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean array value [true, 'boolean', false] @@ -382,7 +382,7 @@ def get_boolean_invalid_string( return deserialized def get_integer_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer array value [1, -1, 3, 300] @@ -426,7 +426,7 @@ def get_integer_valid( return deserialized def put_integer_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value empty [1, -1, 3, 300] @@ -469,7 +469,7 @@ def put_integer_valid( return client_raw_response def get_int_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer array value [1, null, 0] @@ -513,7 +513,7 @@ def get_int_invalid_null( return deserialized def get_int_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer array value [1, 'integer', 0] @@ -557,7 +557,7 @@ def get_int_invalid_string( return deserialized def get_long_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer array value [1, -1, 3, 300] @@ -601,7 +601,7 @@ def get_long_valid( return deserialized def put_long_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value empty [1, -1, 3, 300] @@ -644,7 +644,7 @@ def put_long_valid( return client_raw_response def get_long_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get long array value [1, null, 0] @@ -688,7 +688,7 @@ def get_long_invalid_null( return deserialized def get_long_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get long array value [1, 'integer', 0] @@ -732,7 +732,7 @@ def get_long_invalid_string( return deserialized def get_float_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float array value [0, -0.01, 1.2e20] @@ -776,7 +776,7 @@ def get_float_valid( return deserialized def put_float_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value [0, -0.01, 1.2e20] @@ -819,7 +819,7 @@ def put_float_valid( return client_raw_response def get_float_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float array value [0.0, null, -1.2e20] @@ -863,7 +863,7 @@ def get_float_invalid_null( return deserialized def get_float_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean array value [1.0, 'number', 0.0] @@ -907,7 +907,7 @@ def get_float_invalid_string( return deserialized def get_double_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float array value [0, -0.01, 1.2e20] @@ -951,7 +951,7 @@ def get_double_valid( return deserialized def put_double_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value [0, -0.01, 1.2e20] @@ -994,7 +994,7 @@ def put_double_valid( return client_raw_response def get_double_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float array value [0.0, null, -1.2e20] @@ -1038,7 +1038,7 @@ def get_double_invalid_null( return deserialized def get_double_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean array value [1.0, 'number', 0.0] @@ -1082,7 +1082,7 @@ def get_double_invalid_string( return deserialized def get_string_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string array value ['foo1', 'foo2', 'foo3'] @@ -1126,7 +1126,7 @@ def get_string_valid( return deserialized def put_string_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['foo1', 'foo2', 'foo3'] @@ -1169,7 +1169,7 @@ def put_string_valid( return client_raw_response def get_string_with_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string array value ['foo', null, 'foo2'] @@ -1213,7 +1213,7 @@ def get_string_with_null( return deserialized def get_string_with_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string array value ['foo', 123, 'foo2'] @@ -1257,7 +1257,7 @@ def get_string_with_invalid( return deserialized def get_uuid_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'd1399005-30f7-40d6-8da6-dd7c89ad34db', @@ -1303,7 +1303,7 @@ def get_uuid_valid( return deserialized def put_uuid_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'd1399005-30f7-40d6-8da6-dd7c89ad34db', @@ -1348,7 +1348,7 @@ def put_uuid_valid( return client_raw_response def get_uuid_invalid_chars( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get uuid array value ['6dcc7237-45fe-45c4-8a6b-3a8a3f625652', 'foo'] @@ -1392,7 +1392,7 @@ def get_uuid_invalid_chars( return deserialized def get_date_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer array value ['2000-12-01', '1980-01-02', '1492-10-12'] @@ -1436,7 +1436,7 @@ def get_date_valid( return deserialized def put_date_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['2000-12-01', '1980-01-02', '1492-10-12'] @@ -1479,7 +1479,7 @@ def put_date_valid( return client_raw_response def get_date_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date array value ['2012-01-01', null, '1776-07-04'] @@ -1523,7 +1523,7 @@ def get_date_invalid_null( return deserialized def get_date_invalid_chars( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date array value ['2011-03-22', 'date'] @@ -1567,7 +1567,7 @@ def get_date_invalid_chars( return deserialized def get_date_time_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date-time array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', '1492-10-12T10:15:01-08:00'] @@ -1612,7 +1612,7 @@ def get_date_time_valid( return deserialized def put_date_time_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['2000-12-01t00:00:01z', '1980-01-02T00:11:35+01:00', '1492-10-12T10:15:01-08:00'] @@ -1656,7 +1656,7 @@ def put_date_time_valid( return client_raw_response def get_date_time_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date array value ['2000-12-01t00:00:01z', null] @@ -1700,7 +1700,7 @@ def get_date_time_invalid_null( return deserialized def get_date_time_invalid_chars( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date array value ['2000-12-01t00:00:01z', 'date-time'] @@ -1744,7 +1744,7 @@ def get_date_time_invalid_chars( return deserialized def get_date_time_rfc1123_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date-time array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 Oct 1492 10:15:01 GMT'] @@ -1789,7 +1789,7 @@ def get_date_time_rfc1123_valid( return deserialized def put_date_time_rfc1123_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['Fri, 01 Dec 2000 00:00:01 GMT', 'Wed, 02 Jan 1980 00:11:35 GMT', 'Wed, 12 Oct 1492 10:15:01 GMT'] @@ -1833,7 +1833,7 @@ def put_date_time_rfc1123_valid( return client_raw_response def get_duration_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get duration array value ['P123DT22H14M12.011S', 'P5DT1H0M0S'] @@ -1877,7 +1877,7 @@ def get_duration_valid( return deserialized def put_duration_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set array value ['P123DT22H14M12.011S', 'P5DT1H0M0S'] @@ -1920,7 +1920,7 @@ def put_duration_valid( return client_raw_response def get_byte_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get byte array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each item encoded in base64 @@ -1965,7 +1965,7 @@ def get_byte_valid( return deserialized def put_byte_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put the array value [hex(FF FF FF FA), hex(01 02 03), hex (25, 29, 43)] with each elementencoded in base 64 @@ -2009,7 +2009,7 @@ def put_byte_valid( return client_raw_response def get_byte_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get byte array value [hex(AB, AC, AD), null] with the first item base64 encoded @@ -2054,7 +2054,7 @@ def get_byte_invalid_null( return deserialized def get_base64_url( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get array value ['a string that gets encoded with base64url', 'test string' 'Lorem ipsum'] with the items base64url encoded @@ -2064,7 +2064,7 @@ def get_base64_url( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: list of str + :rtype: list of bytes :rtype: :class:`ClientRawResponse` if raw=true """ @@ -2090,7 +2090,7 @@ def get_base64_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('[str]', response) + deserialized = self._deserialize('[base64]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2099,7 +2099,7 @@ def get_base64_url( return deserialized def get_complex_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get array of complex type null value @@ -2144,7 +2144,7 @@ def get_complex_null( return deserialized def get_complex_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty array of complex type [] @@ -2189,7 +2189,7 @@ def get_complex_empty( return deserialized def get_complex_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get array of complex type with null item [{'integer': 1 'string': '2'}, null, {'integer': 5, 'string': '6'}] @@ -2235,7 +2235,7 @@ def get_complex_item_null( return deserialized def get_complex_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get array of complex type with empty item [{'integer': 1 'string': '2'}, {}, {'integer': 5, 'string': '6'}] @@ -2281,7 +2281,7 @@ def get_complex_item_empty( return deserialized def get_complex_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get array of complex type with [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, {'integer': 5, 'string': '6'}] @@ -2327,7 +2327,7 @@ def get_complex_valid( return deserialized def put_complex_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put an array of complex type with values [{'integer': 1 'string': '2'}, {'integer': 3, 'string': '4'}, {'integer': 5, 'string': '6'}] @@ -2372,7 +2372,7 @@ def put_complex_valid( return client_raw_response def get_array_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a null array @@ -2416,7 +2416,7 @@ def get_array_null( return deserialized def get_array_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an empty array [] @@ -2460,7 +2460,7 @@ def get_array_empty( return deserialized def get_array_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of array of strings [['1', '2', '3'], null, ['7', '8', '9']] @@ -2505,7 +2505,7 @@ def get_array_item_null( return deserialized def get_array_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of array of strings [['1', '2', '3'], [], ['7', '8', '9']] @@ -2549,7 +2549,7 @@ def get_array_item_empty( return deserialized def get_array_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']] @@ -2594,7 +2594,7 @@ def get_array_valid( return deserialized def put_array_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put An array of array of strings [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']] @@ -2638,7 +2638,7 @@ def put_array_valid( return client_raw_response def get_dictionary_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries with value null @@ -2682,7 +2682,7 @@ def get_dictionary_null( return deserialized def get_dictionary_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries of type with value [] @@ -2726,7 +2726,7 @@ def get_dictionary_empty( return deserialized def get_dictionary_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': 'three'}, null, {'7': 'seven', '8': @@ -2772,7 +2772,7 @@ def get_dictionary_item_null( return deserialized def get_dictionary_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': 'three'}, {}, {'7': 'seven', '8': @@ -2818,7 +2818,7 @@ def get_dictionary_item_empty( return deserialized def get_dictionary_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': 'three'}, {'4': 'four', '5': 'five', @@ -2864,7 +2864,7 @@ def get_dictionary_valid( return deserialized def put_dictionary_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Get an array of Dictionaries of type with value [{'1': 'one', '2': 'two', '3': 'three'}, {'4': 'four', '5': 'five', diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/__init__.py index 1a9ee6215ad6b..b5af29ff2dae8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_bool_test_service import AutoRestBoolTestService, AutoRestBoolTestServiceConfiguration +from .auto_rest_bool_test_service import AutoRestBoolTestService from .version import VERSION -__all__ = [ - 'AutoRestBoolTestService', - 'AutoRestBoolTestServiceConfiguration' -] +__all__ = ['AutoRestBoolTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/auto_rest_bool_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/auto_rest_bool_test_service.py index 4b761abb6106a..8cf4e5fffbd36 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/auto_rest_bool_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/auto_rest_bool_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestBoolTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestBoolTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestBoolTestServiceConfiguration :ivar bool_model: BoolModel operations :vartype bool_model: .operations.BoolModel + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestBoolTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.bool_model = BoolModel( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/operations/bool_model.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/operations/bool_model.py index 0ec9dc24c7a63..7476481a89bbf 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/operations/bool_model.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyBoolean/autorestbooltestservice/operations/bool_model.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_true( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get true Boolean value @@ -76,7 +76,7 @@ def get_true( return deserialized def put_true( - self, bool_body, custom_headers={}, raw=False, **operation_config): + self, bool_body, custom_headers=None, raw=False, **operation_config): """ Set Boolean value true @@ -119,7 +119,7 @@ def put_true( return client_raw_response def get_false( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get false Boolean value @@ -163,7 +163,7 @@ def get_false( return deserialized def put_false( - self, bool_body, custom_headers={}, raw=False, **operation_config): + self, bool_body, custom_headers=None, raw=False, **operation_config): """ Set Boolean value false @@ -206,7 +206,7 @@ def put_false( return client_raw_response def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null Boolean value @@ -250,7 +250,7 @@ def get_null( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid Boolean value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/__init__.py index 96f86be7bcf6a..5db23a411c536 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_byte_service import AutoRestSwaggerBATByteService, AutoRestSwaggerBATByteServiceConfiguration +from .auto_rest_swagger_bat_byte_service import AutoRestSwaggerBATByteService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATByteService', - 'AutoRestSwaggerBATByteServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATByteService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/auto_rest_swagger_bat_byte_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/auto_rest_swagger_bat_byte_service.py index 642657c97d75b..5da86b5b91614 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/auto_rest_swagger_bat_byte_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/auto_rest_swagger_bat_byte_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATByteService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATByteServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATByteServiceConfiguration :ivar byte: Byte operations :vartype byte: .operations.Byte + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATByteServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.byte = Byte( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/operations/byte.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/operations/byte.py index f879f85351a00..4c616117291b3 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/operations/byte.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyByte/autorestswaggerbatbyteservice/operations/byte.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null byte value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty byte value '' @@ -120,7 +120,7 @@ def get_empty( return deserialized def get_non_ascii( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6) @@ -164,7 +164,7 @@ def get_non_ascii( return deserialized def put_non_ascii( - self, byte_body, custom_headers={}, raw=False, **operation_config): + self, byte_body, custom_headers=None, raw=False, **operation_config): """ Put non-ascii byte string hex(FF FE FD FC FB FA F9 F8 F7 F6) @@ -208,7 +208,7 @@ def put_non_ascii( return client_raw_response def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid byte value ':::SWAGGER::::' diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/__init__.py index 88a5faf1c85ed..e1df7688a1326 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_complex_test_service import AutoRestComplexTestService, AutoRestComplexTestServiceConfiguration +from .auto_rest_complex_test_service import AutoRestComplexTestService from .version import VERSION -__all__ = [ - 'AutoRestComplexTestService', - 'AutoRestComplexTestServiceConfiguration' -] +__all__ = ['AutoRestComplexTestService'] __version__ = VERSION 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 3887687ac962c..05a5944dc05df 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 @@ -54,8 +54,8 @@ def __init__( class AutoRestComplexTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestComplexTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestComplexTestServiceConfiguration :ivar basic_operations: BasicOperations operations :vartype basic_operations: .operations.BasicOperations @@ -73,17 +73,23 @@ class AutoRestComplexTestService(object): :vartype polymorphicrecursive: .operations.Polymorphicrecursive :ivar readonlyproperty: Readonlyproperty operations :vartype readonlyproperty: .operations.Readonlyproperty + + :param api_version: API ID. + :type api_version: str + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, api_version, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestComplexTestServiceConfiguration(api_version, base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.basic_operations = BasicOperations( self._client, self.config, self._serialize, self._deserialize) self.primitive = Primitive( 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 83a9721456ac7..69a638c4f89c8 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 @@ -21,13 +21,14 @@ class Basic(Model): :type name: str :param color: Possible values include: 'cyan', 'Magenta', 'YELLOW', 'blacK' - :type color: str + :type color: str or :class:`CMYKColors + ` """ _attribute_map = { 'id': {'key': 'id', 'type': 'int'}, 'name': {'key': 'name', 'type': 'str'}, - 'color': {'key': 'color', 'type': 'CMYKColors'}, + 'color': {'key': 'color', 'type': 'str'}, } def __init__(self, id=None, name=None, color=None): diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/array.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/array.py index e375d28d5b3ab..3fb6eec8be8fd 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/array.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/array.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with array property @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, array=None, custom_headers={}, raw=False, **operation_config): + self, array=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with array property @@ -122,7 +122,7 @@ def put_valid( return client_raw_response def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with array property which is empty @@ -167,7 +167,7 @@ def get_empty( return deserialized def put_empty( - self, array=None, custom_headers={}, raw=False, **operation_config): + self, array=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with array property which is empty @@ -212,7 +212,7 @@ def put_empty( return client_raw_response def get_not_provided( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with array property while server doesn't provide a response payload diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/basic_operations.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/basic_operations.py index f1cf4be957c2f..d66a86b411e3b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/basic_operations.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/basic_operations.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex type {id: 2, name: 'abc', color: 'YELLOW'} @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Please put {id: 2, name: 'abc', color: 'Magenta'} @@ -122,7 +122,7 @@ def put_valid( return client_raw_response def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a basic complex type that is invalid for the local strong type @@ -167,7 +167,7 @@ def get_invalid( return deserialized def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a basic complex type that is empty @@ -212,7 +212,7 @@ def get_empty( return deserialized def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a basic complex type whose properties are null @@ -257,7 +257,7 @@ def get_null( return deserialized def get_not_provided( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a basic complex type while the server doesn't provide a response payload diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/dictionary.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/dictionary.py index c99f68238ac66..cc07b65e49e0f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/dictionary.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/dictionary.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with dictionary property @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, default_program=None, custom_headers={}, raw=False, **operation_config): + self, default_program=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with dictionary property @@ -122,7 +122,7 @@ def put_valid( return client_raw_response def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with dictionary property which is empty @@ -167,7 +167,7 @@ def get_empty( return deserialized def put_empty( - self, default_program=None, custom_headers={}, raw=False, **operation_config): + self, default_program=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with dictionary property which is empty @@ -212,7 +212,7 @@ def put_empty( return client_raw_response def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with dictionary property which is null @@ -257,7 +257,7 @@ def get_null( return deserialized def get_not_provided( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with dictionary property while server doesn't provide a response payload diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/inheritance.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/inheritance.py index 94062da6c3bf5..37bf308be2fd0 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/inheritance.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/inheritance.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types that extend others @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types that extend others diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphicrecursive.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphicrecursive.py index d2aadc47ad3a8..451955b6fee23 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphicrecursive.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphicrecursive.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types that are polymorphic and have recursive references @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types that are polymorphic and have recursive references diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphism.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphism.py index 3b3d75f90dfb2..e85c471abf09a 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphism.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/polymorphism.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types that are polymorphic @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types that are polymorphic @@ -154,7 +154,7 @@ def put_valid( return client_raw_response def put_valid_missing_required( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types that are polymorphic, attempting to omit required 'birthday' field - the request should not be allowed from the client diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/primitive.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/primitive.py index de0386c4de16e..ca9e56f8d0b02 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/primitive.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/primitive.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_int( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with integer properties @@ -77,7 +77,7 @@ def get_int( return deserialized def put_int( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with integer properties @@ -121,7 +121,7 @@ def put_int( return client_raw_response def get_long( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with long properties @@ -166,7 +166,7 @@ def get_long( return deserialized def put_long( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with long properties @@ -210,7 +210,7 @@ def put_long( return client_raw_response def get_float( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with float properties @@ -255,7 +255,7 @@ def get_float( return deserialized def put_float( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with float properties @@ -299,7 +299,7 @@ def put_float( return client_raw_response def get_double( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with double properties @@ -344,7 +344,7 @@ def get_double( return deserialized def put_double( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with double properties @@ -389,7 +389,7 @@ def put_double( return client_raw_response def get_bool( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with bool properties @@ -434,7 +434,7 @@ def get_bool( return deserialized def put_bool( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with bool properties @@ -478,7 +478,7 @@ def put_bool( return client_raw_response def get_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with string properties @@ -523,7 +523,7 @@ def get_string( return deserialized def put_string( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with string properties @@ -567,7 +567,7 @@ def put_string( return client_raw_response def get_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with date properties @@ -612,7 +612,7 @@ def get_date( return deserialized def put_date( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with date properties @@ -656,7 +656,7 @@ def put_date( return client_raw_response def get_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with datetime properties @@ -701,7 +701,7 @@ def get_date_time( return deserialized def put_date_time( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with datetime properties @@ -746,7 +746,7 @@ def put_date_time( return client_raw_response def get_date_time_rfc1123( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with datetimeRfc1123 properties @@ -791,7 +791,7 @@ def get_date_time_rfc1123( return deserialized def put_date_time_rfc1123( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types with datetimeRfc1123 properties @@ -836,7 +836,7 @@ def put_date_time_rfc1123( return client_raw_response def get_duration( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with duration properties @@ -881,7 +881,7 @@ def get_duration( return deserialized def put_duration( - self, field=None, custom_headers={}, raw=False, **operation_config): + self, field=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with duration properties @@ -926,7 +926,7 @@ def put_duration( return client_raw_response def get_byte( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types with byte properties @@ -971,7 +971,7 @@ def get_byte( return deserialized def put_byte( - self, field=None, custom_headers={}, raw=False, **operation_config): + self, field=None, custom_headers=None, raw=False, **operation_config): """ Put complex types with byte properties diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/readonlyproperty.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/readonlyproperty.py index fde563ffc3a26..d8505c972da66 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/readonlyproperty.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/operations/readonlyproperty.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get complex types that have readonly properties @@ -77,7 +77,7 @@ def get_valid( return deserialized def put_valid( - self, complex_body, custom_headers={}, raw=False, **operation_config): + self, complex_body, custom_headers=None, raw=False, **operation_config): """ Put complex types that have readonly properties diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/__init__.py index b7af2707b1e97..f8fdc22a6549a 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_date_test_service import AutoRestDateTestService, AutoRestDateTestServiceConfiguration +from .auto_rest_date_test_service import AutoRestDateTestService from .version import VERSION -__all__ = [ - 'AutoRestDateTestService', - 'AutoRestDateTestServiceConfiguration' -] +__all__ = ['AutoRestDateTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/auto_rest_date_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/auto_rest_date_test_service.py index 0f74549ec39ad..c37507db7fdd4 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/auto_rest_date_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/auto_rest_date_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestDateTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestDateTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestDateTestServiceConfiguration :ivar date_model: DateModel operations :vartype date_model: .operations.DateModel + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestDateTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.date_model = DateModel( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/operations/date_model.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/operations/date_model.py index c0b1f47c71e04..4f0f9e778d427 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/operations/date_model.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDate/autorestdatetestservice/operations/date_model.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null date value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid date value @@ -120,7 +120,7 @@ def get_invalid_date( return deserialized def get_overflow_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get overflow date value @@ -164,7 +164,7 @@ def get_overflow_date( return deserialized def get_underflow_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get underflow date value @@ -208,7 +208,7 @@ def get_underflow_date( return deserialized def put_max_date( - self, date_body, custom_headers={}, raw=False, **operation_config): + self, date_body, custom_headers=None, raw=False, **operation_config): """ Put max date value 9999-12-31 @@ -251,7 +251,7 @@ def put_max_date( return client_raw_response def get_max_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max date value 9999-12-31 @@ -295,7 +295,7 @@ def get_max_date( return deserialized def put_min_date( - self, date_body, custom_headers={}, raw=False, **operation_config): + self, date_body, custom_headers=None, raw=False, **operation_config): """ Put min date value 0000-01-01 @@ -338,7 +338,7 @@ def put_min_date( return client_raw_response def get_min_date( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get min date value 0000-01-01 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/__init__.py index 715d9b2347be7..40d7df46c4ee7 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_date_time_test_service import AutoRestDateTimeTestService, AutoRestDateTimeTestServiceConfiguration +from .auto_rest_date_time_test_service import AutoRestDateTimeTestService from .version import VERSION -__all__ = [ - 'AutoRestDateTimeTestService', - 'AutoRestDateTimeTestServiceConfiguration' -] +__all__ = ['AutoRestDateTimeTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/auto_rest_date_time_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/auto_rest_date_time_test_service.py index ccfa0103070cd..a7189bd413fdf 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/auto_rest_date_time_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/auto_rest_date_time_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestDateTimeTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestDateTimeTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestDateTimeTestServiceConfiguration :ivar datetime_model: DatetimeModel operations :vartype datetime_model: .operations.DatetimeModel + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestDateTimeTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.datetime_model = DatetimeModel( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/operations/datetime_model.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/operations/datetime_model.py index 36fe8312b4a8a..b4412d87ef4a7 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/operations/datetime_model.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTime/autorestdatetimetestservice/operations/datetime_model.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null datetime value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid datetime value @@ -120,7 +120,7 @@ def get_invalid( return deserialized def get_overflow( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get overflow datetime value @@ -164,7 +164,7 @@ def get_overflow( return deserialized def get_underflow( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get underflow datetime value @@ -208,7 +208,7 @@ def get_underflow( return deserialized def put_utc_max_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put max datetime value 9999-12-31T23:59:59.9999999Z @@ -251,7 +251,7 @@ def put_utc_max_date_time( return client_raw_response def get_utc_lowercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value 9999-12-31t23:59:59.9999999z @@ -295,7 +295,7 @@ def get_utc_lowercase_max_date_time( return deserialized def get_utc_uppercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value 9999-12-31T23:59:59.9999999Z @@ -339,7 +339,7 @@ def get_utc_uppercase_max_date_time( return deserialized def put_local_positive_offset_max_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put max datetime value with positive numoffset 9999-12-31t23:59:59.9999999+14:00 @@ -383,7 +383,7 @@ def put_local_positive_offset_max_date_time( return client_raw_response def get_local_positive_offset_lowercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value with positive num offset 9999-12-31t23:59:59.9999999+14:00 @@ -428,7 +428,7 @@ def get_local_positive_offset_lowercase_max_date_time( return deserialized def get_local_positive_offset_uppercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value with positive num offset 9999-12-31T23:59:59.9999999+14:00 @@ -473,7 +473,7 @@ def get_local_positive_offset_uppercase_max_date_time( return deserialized def put_local_negative_offset_max_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put max datetime value with positive numoffset 9999-12-31t23:59:59.9999999-14:00 @@ -517,7 +517,7 @@ def put_local_negative_offset_max_date_time( return client_raw_response def get_local_negative_offset_uppercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value with positive num offset 9999-12-31T23:59:59.9999999-14:00 @@ -562,7 +562,7 @@ def get_local_negative_offset_uppercase_max_date_time( return deserialized def get_local_negative_offset_lowercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value with positive num offset 9999-12-31t23:59:59.9999999-14:00 @@ -607,7 +607,7 @@ def get_local_negative_offset_lowercase_max_date_time( return deserialized def put_utc_min_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put min datetime value 0001-01-01T00:00:00Z @@ -650,7 +650,7 @@ def put_utc_min_date_time( return client_raw_response def get_utc_min_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get min datetime value 0001-01-01T00:00:00Z @@ -694,7 +694,7 @@ def get_utc_min_date_time( return deserialized def put_local_positive_offset_min_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put min datetime value 0001-01-01T00:00:00+14:00 @@ -737,7 +737,7 @@ def put_local_positive_offset_min_date_time( return client_raw_response def get_local_positive_offset_min_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get min datetime value 0001-01-01T00:00:00+14:00 @@ -781,7 +781,7 @@ def get_local_positive_offset_min_date_time( return deserialized def put_local_negative_offset_min_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put min datetime value 0001-01-01T00:00:00-14:00 @@ -824,7 +824,7 @@ def put_local_negative_offset_min_date_time( return client_raw_response def get_local_negative_offset_min_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get min datetime value 0001-01-01T00:00:00-14:00 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/__init__.py index 6ce64523d9928..85daa6afc2506 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_rfc1123_date_time_test_service import AutoRestRFC1123DateTimeTestService, AutoRestRFC1123DateTimeTestServiceConfiguration +from .auto_rest_rfc1123_date_time_test_service import AutoRestRFC1123DateTimeTestService from .version import VERSION -__all__ = [ - 'AutoRestRFC1123DateTimeTestService', - 'AutoRestRFC1123DateTimeTestServiceConfiguration' -] +__all__ = ['AutoRestRFC1123DateTimeTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/auto_rest_rfc1123_date_time_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/auto_rest_rfc1123_date_time_test_service.py index 0863e02445f74..8ba043959a650 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/auto_rest_rfc1123_date_time_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/auto_rest_rfc1123_date_time_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestRFC1123DateTimeTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestRFC1123DateTimeTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestRFC1123DateTimeTestServiceConfiguration :ivar datetimerfc1123: Datetimerfc1123 operations :vartype datetimerfc1123: .operations.Datetimerfc1123 + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestRFC1123DateTimeTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.datetimerfc1123 = Datetimerfc1123( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/operations/datetimerfc1123.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/operations/datetimerfc1123.py index 679bb0be6bc1d..1d9e03f21416f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/operations/datetimerfc1123.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/autorestrfc1123datetimetestservice/operations/datetimerfc1123.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null datetime value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid datetime value @@ -120,7 +120,7 @@ def get_invalid( return deserialized def get_overflow( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get overflow datetime value @@ -164,7 +164,7 @@ def get_overflow( return deserialized def get_underflow( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get underflow datetime value @@ -208,7 +208,7 @@ def get_underflow( return deserialized def put_utc_max_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put max datetime value Fri, 31 Dec 9999 23:59:59 GMT @@ -251,7 +251,7 @@ def put_utc_max_date_time( return client_raw_response def get_utc_lowercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value fri, 31 dec 9999 23:59:59 gmt @@ -295,7 +295,7 @@ def get_utc_lowercase_max_date_time( return deserialized def get_utc_uppercase_max_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get max datetime value FRI, 31 DEC 9999 23:59:59 GMT @@ -339,7 +339,7 @@ def get_utc_uppercase_max_date_time( return deserialized def put_utc_min_date_time( - self, datetime_body, custom_headers={}, raw=False, **operation_config): + self, datetime_body, custom_headers=None, raw=False, **operation_config): """ Put min datetime value Mon, 1 Jan 0001 00:00:00 GMT @@ -382,7 +382,7 @@ def put_utc_min_date_time( return client_raw_response def get_utc_min_date_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get min datetime value Mon, 1 Jan 0001 00:00:00 GMT diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/__init__.py index b835d08c52f18..81ebb3c0c24dc 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_ba_tdictionary_service import AutoRestSwaggerBATdictionaryService, AutoRestSwaggerBATdictionaryServiceConfiguration +from .auto_rest_swagger_ba_tdictionary_service import AutoRestSwaggerBATdictionaryService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATdictionaryService', - 'AutoRestSwaggerBATdictionaryServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATdictionaryService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/auto_rest_swagger_ba_tdictionary_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/auto_rest_swagger_ba_tdictionary_service.py index 0347ffaeef4cd..7ec28039bc2a7 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/auto_rest_swagger_ba_tdictionary_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/auto_rest_swagger_ba_tdictionary_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATdictionaryService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATdictionaryServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATdictionaryServiceConfiguration :ivar dictionary: Dictionary operations :vartype dictionary: .operations.Dictionary + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATdictionaryServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.dictionary = Dictionary( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/operations/dictionary.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/operations/dictionary.py index 55fd8ef1953dc..5744c23adfac8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/operations/dictionary.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDictionary/autorestswaggerbatdictionaryservice/operations/dictionary.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null dictionary value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty dictionary value {} @@ -120,7 +120,7 @@ def get_empty( return deserialized def put_empty( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value empty {} @@ -163,7 +163,7 @@ def put_empty( return client_raw_response def get_null_value( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get Dictionary with null value @@ -207,7 +207,7 @@ def get_null_value( return deserialized def get_null_key( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get Dictionary with null key @@ -251,7 +251,7 @@ def get_null_key( return deserialized def get_empty_string_key( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get Dictionary with key as empty string @@ -295,7 +295,7 @@ def get_empty_string_key( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid Dictionary value @@ -339,7 +339,7 @@ def get_invalid( return deserialized def get_boolean_tfft( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean dictionary value {"0": true, "1": false, "2": false, "3": true } @@ -384,7 +384,7 @@ def get_boolean_tfft( return deserialized def put_boolean_tfft( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value empty {"0": true, "1": false, "2": false, "3": true } @@ -428,7 +428,7 @@ def put_boolean_tfft( return client_raw_response def get_boolean_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean dictionary value {"0": true, "1": null, "2": false } @@ -472,7 +472,7 @@ def get_boolean_invalid_null( return deserialized def get_boolean_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean dictionary value '{"0": true, "1": "boolean", "2": false}' @@ -516,7 +516,7 @@ def get_boolean_invalid_string( return deserialized def get_integer_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300} @@ -560,7 +560,7 @@ def get_integer_valid( return deserialized def put_integer_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300} @@ -603,7 +603,7 @@ def put_integer_valid( return client_raw_response def get_int_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer dictionary value {"0": 1, "1": null, "2": 0} @@ -647,7 +647,7 @@ def get_int_invalid_null( return deserialized def get_int_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer dictionary value {"0": 1, "1": "integer", "2": 0} @@ -691,7 +691,7 @@ def get_int_invalid_string( return deserialized def get_long_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer dictionary value {"0": 1, "1": -1, "2": 3, "3": 300} @@ -735,7 +735,7 @@ def get_long_valid( return deserialized def put_long_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value empty {"0": 1, "1": -1, "2": 3, "3": 300} @@ -778,7 +778,7 @@ def put_long_valid( return client_raw_response def get_long_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get long dictionary value {"0": 1, "1": null, "2": 0} @@ -822,7 +822,7 @@ def get_long_invalid_null( return deserialized def get_long_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get long dictionary value {"0": 1, "1": "integer", "2": 0} @@ -866,7 +866,7 @@ def get_long_invalid_string( return deserialized def get_float_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20} @@ -910,7 +910,7 @@ def get_float_valid( return deserialized def put_float_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20} @@ -953,7 +953,7 @@ def put_float_valid( return client_raw_response def get_float_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20} @@ -997,7 +997,7 @@ def get_float_invalid_null( return deserialized def get_float_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0} @@ -1041,7 +1041,7 @@ def get_float_invalid_string( return deserialized def get_double_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float dictionary value {"0": 0, "1": -0.01, "2": 1.2e20} @@ -1085,7 +1085,7 @@ def get_double_valid( return deserialized def put_double_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": 0, "1": -0.01, "2": 1.2e20} @@ -1128,7 +1128,7 @@ def put_double_valid( return client_raw_response def get_double_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get float dictionary value {"0": 0.0, "1": null, "2": 1.2e20} @@ -1172,7 +1172,7 @@ def get_double_invalid_null( return deserialized def get_double_invalid_string( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get boolean dictionary value {"0": 1.0, "1": "number", "2": 0.0} @@ -1216,7 +1216,7 @@ def get_double_invalid_string( return deserialized def get_string_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"} @@ -1260,7 +1260,7 @@ def get_string_valid( return deserialized def put_string_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": "foo1", "1": "foo2", "2": "foo3"} @@ -1303,7 +1303,7 @@ def put_string_valid( return client_raw_response def get_string_with_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string dictionary value {"0": "foo", "1": null, "2": "foo2"} @@ -1347,7 +1347,7 @@ def get_string_with_null( return deserialized def get_string_with_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string dictionary value {"0": "foo", "1": 123, "2": "foo2"} @@ -1391,7 +1391,7 @@ def get_string_with_invalid( return deserialized def get_date_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"} @@ -1436,7 +1436,7 @@ def get_date_valid( return deserialized def put_date_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"} @@ -1480,7 +1480,7 @@ def put_date_valid( return client_raw_response def get_date_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"} @@ -1525,7 +1525,7 @@ def get_date_invalid_null( return deserialized def get_date_invalid_chars( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date dictionary value {"0": "2011-03-22", "1": "date"} @@ -1569,7 +1569,7 @@ def get_date_invalid_chars( return deserialized def get_date_time_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date-time dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": "1492-10-12T10:15:01-08:00"} @@ -1614,7 +1614,7 @@ def get_date_time_valid( return deserialized def put_date_time_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": "2000-12-01t00:00:01z", "1": "1980-01-02T00:11:35+01:00", "2": "1492-10-12T10:15:01-08:00"} @@ -1658,7 +1658,7 @@ def put_date_time_valid( return client_raw_response def get_date_time_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": null} @@ -1702,7 +1702,7 @@ def get_date_time_invalid_null( return deserialized def get_date_time_invalid_chars( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date dictionary value {"0": "2000-12-01t00:00:01z", "1": "date-time"} @@ -1747,7 +1747,7 @@ def get_date_time_invalid_chars( return deserialized def get_date_time_rfc1123_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get date-time-rfc1123 dictionary value {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 00:11:35 GMT", "2": "Wed, 12 @@ -1793,7 +1793,7 @@ def get_date_time_rfc1123_valid( return deserialized def put_date_time_rfc1123_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value empty {"0": "Fri, 01 Dec 2000 00:00:01 GMT", "1": "Wed, 02 Jan 1980 00:11:35 GMT", "2": "Wed, 12 Oct 1492 10:15:01 GMT"} @@ -1837,7 +1837,7 @@ def put_date_time_rfc1123_valid( return client_raw_response def get_duration_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get duration dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"} @@ -1882,7 +1882,7 @@ def get_duration_valid( return deserialized def put_duration_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Set dictionary value {"0": "P123DT22H14M12.011S", "1": "P5DT1H0M0S"} @@ -1925,7 +1925,7 @@ def put_duration_valid( return client_raw_response def get_byte_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get byte dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} with each item encoded in base64 @@ -1970,7 +1970,7 @@ def get_byte_valid( return deserialized def put_byte_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put the dictionary value {"0": hex(FF FF FF FA), "1": hex(01 02 03), "2": hex (25, 29, 43)} with each elementencoded in base 64 @@ -2014,7 +2014,7 @@ def put_byte_valid( return client_raw_response def get_byte_invalid_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get byte dictionary value {"0": hex(FF FF FF FA), "1": null} with the first item base64 encoded @@ -2059,7 +2059,7 @@ def get_byte_invalid_null( return deserialized def get_base64_url( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get base64url dictionary value {"0": "a string that gets encoded with base64url", "1": "test string", "2": "Lorem ipsum"} @@ -2095,7 +2095,7 @@ def get_base64_url( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('{str}', response) + deserialized = self._deserialize('{base64}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2104,7 +2104,7 @@ def get_base64_url( return deserialized def get_complex_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get dictionary of complex type null value @@ -2148,7 +2148,7 @@ def get_complex_null( return deserialized def get_complex_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty dictionary of complex type {} @@ -2192,7 +2192,7 @@ def get_complex_empty( return deserialized def get_complex_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get dictionary of complex type with null item {"0": {"integer": 1, "string": "2"}, "1": null, "2": {"integer": 5, "string": "6"}} @@ -2237,7 +2237,7 @@ def get_complex_item_null( return deserialized def get_complex_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get dictionary of complex type with empty item {"0": {"integer": 1, "string": "2"}, "1:" {}, "2": {"integer": 5, "string": "6"}} @@ -2282,7 +2282,7 @@ def get_complex_item_empty( return deserialized def get_complex_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get dictionary of complex type with {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, "string": "4"}, "2": {"integer": 5, @@ -2328,7 +2328,7 @@ def get_complex_valid( return deserialized def put_complex_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put an dictionary of complex type with values {"0": {"integer": 1, "string": "2"}, "1": {"integer": 3, "string": "4"}, "2": {"integer": @@ -2373,7 +2373,7 @@ def put_complex_valid( return client_raw_response def get_array_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a null array @@ -2417,7 +2417,7 @@ def get_array_null( return deserialized def get_array_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an empty dictionary {} @@ -2461,7 +2461,7 @@ def get_array_empty( return deserialized def get_array_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionary of array of strings {"0": ["1", "2", "3"], "1": null, "2": ["7", "8", "9"]} @@ -2506,7 +2506,7 @@ def get_array_item_null( return deserialized def get_array_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of array of strings [{"0": ["1", "2", "3"], "1": [], "2": ["7", "8", "9"]} @@ -2551,7 +2551,7 @@ def get_array_item_empty( return deserialized def get_array_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", "9"]} @@ -2596,7 +2596,7 @@ def get_array_valid( return deserialized def put_array_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Put An array of array of strings {"0": ["1", "2", "3"], "1": ["4", "5", "6"], "2": ["7", "8", "9"]} @@ -2640,7 +2640,7 @@ def put_array_valid( return client_raw_response def get_dictionary_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries with value null @@ -2684,7 +2684,7 @@ def get_dictionary_null( return deserialized def get_dictionary_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries of type with value {} @@ -2729,7 +2729,7 @@ def get_dictionary_empty( return deserialized def get_dictionary_item_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": null, "2": @@ -2775,7 +2775,7 @@ def get_dictionary_item_null( return deserialized def get_dictionary_item_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {}, "2": @@ -2821,7 +2821,7 @@ def get_dictionary_item_empty( return deserialized def get_dictionary_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {"4": @@ -2868,7 +2868,7 @@ def get_dictionary_valid( return deserialized def put_dictionary_valid( - self, array_body, custom_headers={}, raw=False, **operation_config): + self, array_body, custom_headers=None, raw=False, **operation_config): """ Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {"4": diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/__init__.py index 2b089964f917f..4ec26f57486df 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_duration_test_service import AutoRestDurationTestService, AutoRestDurationTestServiceConfiguration +from .auto_rest_duration_test_service import AutoRestDurationTestService from .version import VERSION -__all__ = [ - 'AutoRestDurationTestService', - 'AutoRestDurationTestServiceConfiguration' -] +__all__ = ['AutoRestDurationTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py index 6b92034f35796..6160f38a6901b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/auto_rest_duration_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestDurationTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestDurationTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestDurationTestServiceConfiguration :ivar duration: Duration operations :vartype duration: .operations.Duration + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestDurationTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.duration = Duration( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/operations/duration.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/operations/duration.py index d99043d42dc15..1bf3b5a41663c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/operations/duration.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyDuration/autorestdurationtestservice/operations/duration.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null duration value @@ -76,7 +76,7 @@ def get_null( return deserialized def put_positive_duration( - self, duration_body, custom_headers={}, raw=False, **operation_config): + self, duration_body, custom_headers=None, raw=False, **operation_config): """ Put a positive duration value @@ -119,7 +119,7 @@ def put_positive_duration( return client_raw_response def get_positive_duration( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a positive duration value @@ -163,7 +163,7 @@ def get_positive_duration( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get an invalid duration value diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/__init__.py index e50acad67ee85..51dcc09c83649 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_file_service import AutoRestSwaggerBATFileService, AutoRestSwaggerBATFileServiceConfiguration +from .auto_rest_swagger_bat_file_service import AutoRestSwaggerBATFileService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATFileService', - 'AutoRestSwaggerBATFileServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATFileService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/auto_rest_swagger_bat_file_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/auto_rest_swagger_bat_file_service.py index ed4b424e1eee1..b7b44c72d6546 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/auto_rest_swagger_bat_file_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/auto_rest_swagger_bat_file_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATFileService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATFileServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATFileServiceConfiguration :ivar files: Files operations :vartype files: .operations.Files + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATFileServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.files = Files( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/operations/files.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/operations/files.py index d471df199e94a..82b953c456f70 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/operations/files.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFile/autorestswaggerbatfileservice/operations/files.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_file( - self, custom_headers={}, raw=False, callback=None, **operation_config): + self, custom_headers=None, raw=False, callback=None, **operation_config): """ Get file @@ -81,7 +81,7 @@ def get_file( return deserialized def get_file_large( - self, custom_headers={}, raw=False, callback=None, **operation_config): + self, custom_headers=None, raw=False, callback=None, **operation_config): """ Get a large file @@ -130,7 +130,7 @@ def get_file_large( return deserialized def get_empty_file( - self, custom_headers={}, raw=False, callback=None, **operation_config): + self, custom_headers=None, raw=False, callback=None, **operation_config): """ Get empty file diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/__init__.py index 37291171869ef..3460a7aa1b046 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_form_data_service import AutoRestSwaggerBATFormDataService, AutoRestSwaggerBATFormDataServiceConfiguration +from .auto_rest_swagger_bat_form_data_service import AutoRestSwaggerBATFormDataService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATFormDataService', - 'AutoRestSwaggerBATFormDataServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATFormDataService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/auto_rest_swagger_bat_form_data_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/auto_rest_swagger_bat_form_data_service.py index 96060d040eb6f..07c4464eea558 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/auto_rest_swagger_bat_form_data_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/auto_rest_swagger_bat_form_data_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATFormDataService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATFormDataServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATFormDataServiceConfiguration :ivar formdata: Formdata operations :vartype formdata: .operations.Formdata + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATFormDataServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.formdata = Formdata( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/operations/formdata.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/operations/formdata.py index ed3621ac98a0c..99b61bb72e943 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/operations/formdata.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyFormData/autorestswaggerbatformdataservice/operations/formdata.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def upload_file( - self, file_content, file_name, custom_headers={}, raw=False, callback=None, **operation_config): + self, file_content, file_name, custom_headers=None, raw=False, callback=None, **operation_config): """ Upload file @@ -93,7 +93,7 @@ def upload_file( return deserialized def upload_file_via_body( - self, file_content, custom_headers={}, raw=False, callback=None, **operation_config): + self, file_content, custom_headers=None, raw=False, callback=None, **operation_config): """ Upload file diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/__init__.py index 940d02de2bb48..ee85c655bdbb0 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_integer_test_service import AutoRestIntegerTestService, AutoRestIntegerTestServiceConfiguration +from .auto_rest_integer_test_service import AutoRestIntegerTestService from .version import VERSION -__all__ = [ - 'AutoRestIntegerTestService', - 'AutoRestIntegerTestServiceConfiguration' -] +__all__ = ['AutoRestIntegerTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/auto_rest_integer_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/auto_rest_integer_test_service.py index 3fa0acf42d06f..86c9440c50bf1 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/auto_rest_integer_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/auto_rest_integer_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestIntegerTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestIntegerTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestIntegerTestServiceConfiguration :ivar int_model: IntModel operations :vartype int_model: .operations.IntModel + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestIntegerTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.int_model = IntModel( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/operations/int_model.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/operations/int_model.py index a2b06061ed5cb..a0140cff75d04 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/operations/int_model.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyInteger/autorestintegertestservice/operations/int_model.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null Int value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid Int value @@ -120,7 +120,7 @@ def get_invalid( return deserialized def get_overflow_int32( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get overflow Int32 value @@ -164,7 +164,7 @@ def get_overflow_int32( return deserialized def get_underflow_int32( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get underflow Int32 value @@ -208,7 +208,7 @@ def get_underflow_int32( return deserialized def get_overflow_int64( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get overflow Int64 value @@ -252,7 +252,7 @@ def get_overflow_int64( return deserialized def get_underflow_int64( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get underflow Int64 value @@ -296,7 +296,7 @@ def get_underflow_int64( return deserialized def put_max32( - self, int_body, custom_headers={}, raw=False, **operation_config): + self, int_body, custom_headers=None, raw=False, **operation_config): """ Put max int32 value @@ -339,7 +339,7 @@ def put_max32( return client_raw_response def put_max64( - self, int_body, custom_headers={}, raw=False, **operation_config): + self, int_body, custom_headers=None, raw=False, **operation_config): """ Put max int64 value @@ -382,7 +382,7 @@ def put_max64( return client_raw_response def put_min32( - self, int_body, custom_headers={}, raw=False, **operation_config): + self, int_body, custom_headers=None, raw=False, **operation_config): """ Put min int32 value @@ -425,7 +425,7 @@ def put_min32( return client_raw_response def put_min64( - self, int_body, custom_headers={}, raw=False, **operation_config): + self, int_body, custom_headers=None, raw=False, **operation_config): """ Put min int64 value @@ -468,7 +468,7 @@ def put_min64( return client_raw_response def get_unix_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get datetime encoded as Unix time value @@ -477,7 +477,7 @@ def get_unix_time( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: long + :rtype: datetime :rtype: :class:`ClientRawResponse` if raw=true """ @@ -503,7 +503,7 @@ def get_unix_time( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('long', response) + deserialized = self._deserialize('unix-time', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -512,12 +512,12 @@ def get_unix_time( return deserialized def put_unix_time_date( - self, int_body, custom_headers={}, raw=False, **operation_config): + self, int_body, custom_headers=None, raw=False, **operation_config): """ Put datetime encoded as Unix time :param int_body: - :type int_body: long + :type int_body: datetime :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -540,7 +540,7 @@ def put_unix_time_date( header_parameters.update(custom_headers) # Construct body - body_content = self._serialize.body(int_body, 'long') + body_content = self._serialize.body(int_body, 'unix-time') # Construct and send request request = self._client.put(url, query_parameters) @@ -555,7 +555,7 @@ def put_unix_time_date( return client_raw_response def get_invalid_unix_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid Unix time value @@ -564,7 +564,7 @@ def get_invalid_unix_time( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: long + :rtype: datetime :rtype: :class:`ClientRawResponse` if raw=true """ @@ -590,7 +590,7 @@ def get_invalid_unix_time( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('long', response) + deserialized = self._deserialize('unix-time', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -599,7 +599,7 @@ def get_invalid_unix_time( return deserialized def get_null_unix_time( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null Unix time value @@ -608,7 +608,7 @@ def get_null_unix_time( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: long + :rtype: datetime :rtype: :class:`ClientRawResponse` if raw=true """ @@ -634,7 +634,7 @@ def get_null_unix_time( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('long', response) + deserialized = self._deserialize('unix-time', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/__init__.py index 2de2f291c3a91..b43669b4296b1 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_number_test_service import AutoRestNumberTestService, AutoRestNumberTestServiceConfiguration +from .auto_rest_number_test_service import AutoRestNumberTestService from .version import VERSION -__all__ = [ - 'AutoRestNumberTestService', - 'AutoRestNumberTestServiceConfiguration' -] +__all__ = ['AutoRestNumberTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/auto_rest_number_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/auto_rest_number_test_service.py index ff0cbc28173b6..0f445b717a5e1 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/auto_rest_number_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/auto_rest_number_test_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestNumberTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestNumberTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestNumberTestServiceConfiguration :ivar number: Number operations :vartype number: .operations.Number + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestNumberTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.number = Number( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/operations/number.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/operations/number.py index bfc4e6c78c82c..407caf3075958 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/operations/number.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyNumber/autorestnumbertestservice/operations/number.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null Number value @@ -76,7 +76,7 @@ def get_null( return deserialized def get_invalid_float( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid float Number value @@ -120,7 +120,7 @@ def get_invalid_float( return deserialized def get_invalid_double( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid double Number value @@ -164,7 +164,7 @@ def get_invalid_double( return deserialized def get_invalid_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get invalid decimal Number value @@ -208,7 +208,7 @@ def get_invalid_decimal( return deserialized def put_big_float( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big float value 3.402823e+20 @@ -251,7 +251,7 @@ def put_big_float( return client_raw_response def get_big_float( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big float value 3.402823e+20 @@ -295,7 +295,7 @@ def get_big_float( return deserialized def put_big_double( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big double value 2.5976931e+101 @@ -338,7 +338,7 @@ def put_big_double( return client_raw_response def get_big_double( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big double value 2.5976931e+101 @@ -382,7 +382,7 @@ def get_big_double( return deserialized def put_big_double_positive_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big double value 99999999.99 @@ -425,7 +425,7 @@ def put_big_double_positive_decimal( return client_raw_response def get_big_double_positive_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big double value 99999999.99 @@ -469,7 +469,7 @@ def get_big_double_positive_decimal( return deserialized def put_big_double_negative_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big double value -99999999.99 @@ -512,7 +512,7 @@ def put_big_double_negative_decimal( return client_raw_response def get_big_double_negative_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big double value -99999999.99 @@ -556,7 +556,7 @@ def get_big_double_negative_decimal( return deserialized def put_big_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big decimal value 2.5976931e+101 @@ -599,7 +599,7 @@ def put_big_decimal( return client_raw_response def get_big_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big decimal value 2.5976931e+101 @@ -643,7 +643,7 @@ def get_big_decimal( return deserialized def put_big_decimal_positive_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big decimal value 99999999.99 @@ -686,7 +686,7 @@ def put_big_decimal_positive_decimal( return client_raw_response def get_big_decimal_positive_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big decimal value 99999999.99 @@ -730,7 +730,7 @@ def get_big_decimal_positive_decimal( return deserialized def put_big_decimal_negative_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put big decimal value -99999999.99 @@ -773,7 +773,7 @@ def put_big_decimal_negative_decimal( return client_raw_response def get_big_decimal_negative_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big decimal value -99999999.99 @@ -817,7 +817,7 @@ def get_big_decimal_negative_decimal( return deserialized def put_small_float( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put small float value 3.402823e-20 @@ -860,7 +860,7 @@ def put_small_float( return client_raw_response def get_small_float( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big double value 3.402823e-20 @@ -904,7 +904,7 @@ def get_small_float( return deserialized def put_small_double( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put small double value 2.5976931e-101 @@ -947,7 +947,7 @@ def put_small_double( return client_raw_response def get_small_double( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get big double value 2.5976931e-101 @@ -991,7 +991,7 @@ def get_small_double( return deserialized def put_small_decimal( - self, number_body, custom_headers={}, raw=False, **operation_config): + self, number_body, custom_headers=None, raw=False, **operation_config): """ Put small decimal value 2.5976931e-101 @@ -1034,7 +1034,7 @@ def put_small_decimal( return client_raw_response def get_small_decimal( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get small decimal value 2.5976931e-101 diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/__init__.py index 6f40aa482a0e5..e9981a1677572 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_service import AutoRestSwaggerBATService, AutoRestSwaggerBATServiceConfiguration +from .auto_rest_swagger_bat_service import AutoRestSwaggerBATService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATService', - 'AutoRestSwaggerBATServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/auto_rest_swagger_bat_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/auto_rest_swagger_bat_service.py index 8f31568d50797..cb1ce26901fe2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/auto_rest_swagger_bat_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/auto_rest_swagger_bat_service.py @@ -40,24 +40,28 @@ def __init__( class AutoRestSwaggerBATService(object): """Test Infrastructure for AutoRest Swagger BAT - :param config: Configuration for client. - :type config: AutoRestSwaggerBATServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATServiceConfiguration :ivar string: String operations :vartype string: .operations.String :ivar enum: Enum operations :vartype enum: .operations.Enum + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.string = String( self._client, self.config, self._serialize, self._deserialize) self.enum = Enum( diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/enum.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/enum.py index 3036a22fa9a19..9880ab28e0910 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/enum.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/enum.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_not_expandable( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get enum value 'red color' from enumeration of 'red color', 'green-color', 'blue_color'. @@ -42,7 +42,7 @@ def get_not_expandable( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: str + :rtype: :class:`Colors ` :rtype: :class:`ClientRawResponse` if raw=true """ @@ -77,14 +77,15 @@ def get_not_expandable( return deserialized def put_not_expandable( - self, string_body, custom_headers={}, raw=False, **operation_config): + self, string_body, custom_headers=None, raw=False, **operation_config): """ Sends value 'red color' from enumeration of 'red color', 'green-color', 'blue_color' :param string_body: Possible values include: 'red color', 'green-color', 'blue_color' - :type string_body: str + :type string_body: str or :class:`Colors + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/string.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/string.py index 5910495329f88..09a976276385c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/string.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyString/autorestswaggerbatservice/operations/string.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_null( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null string value value @@ -76,7 +76,7 @@ def get_null( return deserialized def put_null( - self, string_body=None, custom_headers={}, raw=False, **operation_config): + self, string_body=None, custom_headers=None, raw=False, **operation_config): """ Set string value null @@ -122,7 +122,7 @@ def put_null( return client_raw_response def get_empty( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty string value value '' @@ -166,7 +166,7 @@ def get_empty( return deserialized def put_empty( - self, string_body, custom_headers={}, raw=False, **operation_config): + self, string_body, custom_headers=None, raw=False, **operation_config): """ Set string value empty '' @@ -209,7 +209,7 @@ def put_empty( return client_raw_response def get_mbcs( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get mbcs string value '啊齄丂狛狜隣郎隣兀﨩ˊ▇█〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€ @@ -255,7 +255,7 @@ def get_mbcs( return deserialized def put_mbcs( - self, string_body, custom_headers={}, raw=False, **operation_config): + self, string_body, custom_headers=None, raw=False, **operation_config): """ Set string value mbcs '啊齄丂狛狜隣郎隣兀﨩ˊ▇█〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€ @@ -302,7 +302,7 @@ def put_mbcs( return client_raw_response def get_whitespace( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get string value with leading and trailing whitespace 'Now is the time for all good men to come to the @@ -348,7 +348,7 @@ def get_whitespace( return deserialized def put_whitespace( - self, string_body, custom_headers={}, raw=False, **operation_config): + self, string_body, custom_headers=None, raw=False, **operation_config): """ Set String value with leading and trailing whitespace 'Now is the time for all good men to come to the @@ -394,7 +394,7 @@ def put_whitespace( return client_raw_response def get_not_provided( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get String value when no string value is sent in response payload @@ -438,7 +438,7 @@ def get_not_provided( return deserialized def get_base64_encoded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get value that is base64 encoded @@ -447,7 +447,7 @@ def get_base64_encoded( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: str + :rtype: bytes :rtype: :class:`ClientRawResponse` if raw=true """ @@ -473,7 +473,7 @@ def get_base64_encoded( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('str', response) + deserialized = self._deserialize('base64', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -482,7 +482,7 @@ def get_base64_encoded( return deserialized def get_base64_url_encoded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get value that is base64url encoded @@ -491,7 +491,7 @@ def get_base64_url_encoded( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: str + :rtype: bytes :rtype: :class:`ClientRawResponse` if raw=true """ @@ -517,7 +517,7 @@ def get_base64_url_encoded( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('str', response) + deserialized = self._deserialize('base64', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -526,12 +526,12 @@ def get_base64_url_encoded( return deserialized def put_base64_url_encoded( - self, string_body, custom_headers={}, raw=False, **operation_config): + self, string_body, custom_headers=None, raw=False, **operation_config): """ Put value that is base64url encoded :param string_body: - :type string_body: str + :type string_body: bytes :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -554,7 +554,7 @@ def put_base64_url_encoded( header_parameters.update(custom_headers) # Construct body - body_content = self._serialize.body(string_body, 'str') + body_content = self._serialize.body(string_body, 'base64') # Construct and send request request = self._client.put(url, query_parameters) @@ -569,7 +569,7 @@ def put_base64_url_encoded( return client_raw_response def get_null_base64_url_encoded( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get null value that is expected to be base64url encoded @@ -578,7 +578,7 @@ def get_null_base64_url_encoded( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :rtype: str + :rtype: bytes :rtype: :class:`ClientRawResponse` if raw=true """ @@ -604,7 +604,7 @@ def get_null_base64_url_encoded( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('str', response) + deserialized = self._deserialize('base64', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py index ba883e5e5ac44..55019b8878d29 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient, AutoRestParameterizedHostTestClientConfiguration +from .auto_rest_parameterized_host_test_client import AutoRestParameterizedHostTestClient from .version import VERSION -__all__ = [ - 'AutoRestParameterizedHostTestClient', - 'AutoRestParameterizedHostTestClientConfiguration' -] +__all__ = ['AutoRestParameterizedHostTestClient'] __version__ = VERSION 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 5839338b5a2d2..14b292dfa6387 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 @@ -46,21 +46,27 @@ def __init__( class AutoRestParameterizedHostTestClient(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestParameterizedHostTestClientConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestParameterizedHostTestClientConfiguration :ivar paths: Paths operations :vartype paths: .operations.Paths + + :param host: A string value that is used as a global part of the + parameterized host + :type host: str + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, host, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestParameterizedHostTestClientConfiguration(host, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) 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/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths.py index 4d021f1088d59..478f2a330a550 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUri/autorestparameterizedhosttestclient/operations/paths.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_empty( - self, account_name, custom_headers={}, raw=False, **operation_config): + self, account_name, custom_headers=None, raw=False, **operation_config): """ Get a 200 to test a valid base uri 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 index 6711cf5b14df9..edfa86f280067 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_parameterized_custom_host_test_client import AutoRestParameterizedCustomHostTestClient, AutoRestParameterizedCustomHostTestClientConfiguration +from .auto_rest_parameterized_custom_host_test_client import AutoRestParameterizedCustomHostTestClient from .version import VERSION -__all__ = [ - 'AutoRestParameterizedCustomHostTestClient', - 'AutoRestParameterizedCustomHostTestClientConfiguration' -] +__all__ = ['AutoRestParameterizedCustomHostTestClient'] __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 index 6a61d697f46ef..9e5500f342c28 100644 --- 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 @@ -53,21 +53,29 @@ def __init__( class AutoRestParameterizedCustomHostTestClient(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestParameterizedCustomHostTestClientConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestParameterizedCustomHostTestClientConfiguration :ivar paths: Paths operations :vartype paths: .operations.Paths + + :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, config): + def __init__( + self, subscription_id, dns_suffix, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestParameterizedCustomHostTestClientConfiguration(subscription_id, dns_suffix, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) 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/operations/paths.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/autorestparameterizedcustomhosttestclient/operations/paths.py index 2c43f455f742d..5d17c7e4a6b6a 100644 --- 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 @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_empty( - self, vault, secret, key_name, key_version="v1", custom_headers={}, raw=False, **operation_config): + self, vault, secret, key_name, key_version="v1", custom_headers=None, raw=False, **operation_config): """ Get a 200 to test a valid base uri diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/__init__.py index 6068e7d5e068d..60f936ea909a8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_swagger_bat_header_service import AutoRestSwaggerBATHeaderService, AutoRestSwaggerBATHeaderServiceConfiguration +from .auto_rest_swagger_bat_header_service import AutoRestSwaggerBATHeaderService from .version import VERSION -__all__ = [ - 'AutoRestSwaggerBATHeaderService', - 'AutoRestSwaggerBATHeaderServiceConfiguration' -] +__all__ = ['AutoRestSwaggerBATHeaderService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/auto_rest_swagger_bat_header_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/auto_rest_swagger_bat_header_service.py index 65e70d44935bb..2b6e1e65a98ab 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/auto_rest_swagger_bat_header_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/auto_rest_swagger_bat_header_service.py @@ -39,21 +39,25 @@ def __init__( class AutoRestSwaggerBATHeaderService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestSwaggerBATHeaderServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestSwaggerBATHeaderServiceConfiguration :ivar header: Header operations :vartype header: .operations.Header + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestSwaggerBATHeaderServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.header = Header( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/operations/header.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/operations/header.py index 55f4a77cbee80..22fc077e71f66 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/operations/header.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Header/autorestswaggerbatheaderservice/operations/header.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def param_existing_key( - self, user_agent, custom_headers={}, raw=False, **operation_config): + self, user_agent, custom_headers=None, raw=False, **operation_config): """ Send a post request with header value "User-Agent": "overwrite" @@ -73,7 +73,7 @@ def param_existing_key( return client_raw_response def response_existing_key( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "User-Agent": "overwrite" @@ -113,7 +113,7 @@ def response_existing_key( return client_raw_response def param_protected_key( - self, content_type, custom_headers={}, raw=False, **operation_config): + self, content_type, custom_headers=None, raw=False, **operation_config): """ Send a post request with header value "Content-Type": "text/html" @@ -154,7 +154,7 @@ def param_protected_key( return client_raw_response def response_protected_key( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "Content-Type": "text/html" @@ -194,7 +194,7 @@ def response_protected_key( return client_raw_response def param_integer( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "positive", "value": 1 or "scenario": "negative", "value": -2 @@ -239,7 +239,7 @@ def param_integer( return client_raw_response def response_integer( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "value": 1 or -2 @@ -283,7 +283,7 @@ def response_integer( return client_raw_response def param_long( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "positive", "value": 105 or "scenario": "negative", "value": -2 @@ -328,7 +328,7 @@ def param_long( return client_raw_response def response_long( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "value": 105 or -2 @@ -372,7 +372,7 @@ def response_long( return client_raw_response def param_float( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "positive", "value": 0.07 or "scenario": "negative", "value": -3.0 @@ -417,7 +417,7 @@ def param_float( return client_raw_response def response_float( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "value": 0.07 or -3.0 @@ -461,7 +461,7 @@ def response_float( return client_raw_response def param_double( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "positive", "value": 7e120 or "scenario": "negative", "value": -3.0 @@ -506,7 +506,7 @@ def param_double( return client_raw_response def response_double( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "value": 7e120 or -3.0 @@ -550,7 +550,7 @@ def response_double( return client_raw_response def param_bool( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "true", "value": true or "scenario": "false", "value": false @@ -595,7 +595,7 @@ def param_bool( return client_raw_response def response_bool( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header value "value": true or false @@ -639,7 +639,7 @@ def response_bool( return client_raw_response def param_string( - self, scenario, value=None, custom_headers={}, raw=False, **operation_config): + self, scenario, value=None, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "The quick brown fox jumps over the lazy dog" or "scenario": "null", @@ -687,7 +687,7 @@ def param_string( return client_raw_response def response_string( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "The quick brown fox jumps over the lazy dog" or null or "" @@ -732,7 +732,7 @@ def response_string( return client_raw_response def param_date( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "2010-01-01" or "scenario": "min", "value": "0001-01-01" @@ -778,7 +778,7 @@ def param_date( return client_raw_response def response_date( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "2010-01-01" or "0001-01-01" @@ -822,7 +822,7 @@ def response_date( return client_raw_response def param_datetime( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "2010-01-01T12:34:56Z" or "scenario": "min", "value": @@ -869,7 +869,7 @@ def param_datetime( return client_raw_response def response_datetime( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "2010-01-01T12:34:56Z" or "0001-01-01T00:00:00Z" @@ -914,7 +914,7 @@ def response_datetime( return client_raw_response def param_datetime_rfc1123( - self, scenario, value=None, custom_headers={}, raw=False, **operation_config): + self, scenario, value=None, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "Wed, 01 Jan 2010 12:34:56 GMT" or "scenario": "min", "value": "Mon, @@ -962,7 +962,7 @@ def param_datetime_rfc1123( return client_raw_response def response_datetime_rfc1123( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "Wed, 01 Jan 2010 12:34:56 GMT" or "Mon, 01 Jan 0001 00:00:00 GMT" @@ -1007,7 +1007,7 @@ def response_datetime_rfc1123( return client_raw_response def param_duration( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "P123DT22H14M12.011S" @@ -1053,7 +1053,7 @@ def param_duration( return client_raw_response def response_duration( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "P123DT22H14M12.011S" @@ -1097,7 +1097,7 @@ def response_duration( return client_raw_response def param_byte( - self, scenario, value, custom_headers={}, raw=False, **operation_config): + self, scenario, value, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "啊齄丂狛狜隣郎隣兀﨩" @@ -1142,7 +1142,7 @@ def param_byte( return client_raw_response def response_byte( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "啊齄丂狛狜隣郎隣兀﨩" @@ -1186,7 +1186,7 @@ def response_byte( return client_raw_response def param_enum( - self, scenario, value=None, custom_headers={}, raw=False, **operation_config): + self, scenario, value=None, custom_headers=None, raw=False, **operation_config): """ Send a post request with header values "scenario": "valid", "value": "GREY" or "scenario": "null", "value": null @@ -1196,7 +1196,8 @@ def param_enum( :type scenario: str :param value: Send a post request with header values 'GREY' . Possible values include: 'White', 'black', 'GREY' - :type value: str + :type value: str or :class:`GreyscaleColors + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1233,7 +1234,7 @@ def param_enum( return client_raw_response def response_enum( - self, scenario, custom_headers={}, raw=False, **operation_config): + self, scenario, custom_headers=None, raw=False, **operation_config): """ Get a response with header values "GREY" or null @@ -1277,7 +1278,7 @@ def response_enum( return client_raw_response def custom_request_id( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 in the header of the request diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/__init__.py index 8e690ea9480fa..539c0efb2a9a9 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_http_infrastructure_test_service import AutoRestHttpInfrastructureTestService, AutoRestHttpInfrastructureTestServiceConfiguration +from .auto_rest_http_infrastructure_test_service import AutoRestHttpInfrastructureTestService from .version import VERSION -__all__ = [ - 'AutoRestHttpInfrastructureTestService', - 'AutoRestHttpInfrastructureTestServiceConfiguration' -] +__all__ = ['AutoRestHttpInfrastructureTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/auto_rest_http_infrastructure_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/auto_rest_http_infrastructure_test_service.py index a70f0e4750f87..c830f26bc2c6f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/auto_rest_http_infrastructure_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/auto_rest_http_infrastructure_test_service.py @@ -45,8 +45,8 @@ def __init__( class AutoRestHttpInfrastructureTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestHttpInfrastructureTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestHttpInfrastructureTestServiceConfiguration :ivar http_failure: HttpFailure operations :vartype http_failure: .operations.HttpFailure @@ -62,17 +62,21 @@ class AutoRestHttpInfrastructureTestService(object): :vartype http_retry: .operations.HttpRetry :ivar multiple_responses: MultipleResponses operations :vartype multiple_responses: .operations.MultipleResponses + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestHttpInfrastructureTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.http_failure = HttpFailure( self._client, self.config, self._serialize, self._deserialize) self.http_success = HttpSuccess( diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_client_failure.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_client_failure.py index 64ad7a1e8b51d..ec65a8c9a8dd5 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_client_failure.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_client_failure.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head400( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -70,7 +70,7 @@ def head400( return client_raw_response def get400( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -108,7 +108,7 @@ def get400( return client_raw_response def put400( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -155,7 +155,7 @@ def put400( return client_raw_response def patch400( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -202,7 +202,7 @@ def patch400( return client_raw_response def post400( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -249,7 +249,7 @@ def post400( return client_raw_response def delete400( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 400 status code - should be represented in the client as an error @@ -296,7 +296,7 @@ def delete400( return client_raw_response def head401( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 401 status code - should be represented in the client as an error @@ -334,7 +334,7 @@ def head401( return client_raw_response def get402( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 402 status code - should be represented in the client as an error @@ -372,7 +372,7 @@ def get402( return client_raw_response def get403( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 403 status code - should be represented in the client as an error @@ -410,7 +410,7 @@ def get403( return client_raw_response def put404( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 404 status code - should be represented in the client as an error @@ -457,7 +457,7 @@ def put404( return client_raw_response def patch405( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 405 status code - should be represented in the client as an error @@ -504,7 +504,7 @@ def patch405( return client_raw_response def post406( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 406 status code - should be represented in the client as an error @@ -551,7 +551,7 @@ def post406( return client_raw_response def delete407( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 407 status code - should be represented in the client as an error @@ -598,7 +598,7 @@ def delete407( return client_raw_response def put409( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 409 status code - should be represented in the client as an error @@ -645,7 +645,7 @@ def put409( return client_raw_response def head410( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 410 status code - should be represented in the client as an error @@ -683,7 +683,7 @@ def head410( return client_raw_response def get411( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 411 status code - should be represented in the client as an error @@ -721,7 +721,7 @@ def get411( return client_raw_response def get412( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 412 status code - should be represented in the client as an error @@ -759,7 +759,7 @@ def get412( return client_raw_response def put413( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 413 status code - should be represented in the client as an error @@ -806,7 +806,7 @@ def put413( return client_raw_response def patch414( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 414 status code - should be represented in the client as an error @@ -853,7 +853,7 @@ def patch414( return client_raw_response def post415( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 415 status code - should be represented in the client as an error @@ -900,7 +900,7 @@ def post415( return client_raw_response def get416( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 416 status code - should be represented in the client as an error @@ -938,7 +938,7 @@ def get416( return client_raw_response def delete417( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 417 status code - should be represented in the client as an error @@ -985,7 +985,7 @@ def delete417( return client_raw_response def head429( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 429 status code - should be represented in the client as an error diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_failure.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_failure.py index 3b6bcfdadbf47..52f9489f48858 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_failure.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_failure.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_empty_error( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty error form server @@ -77,7 +77,7 @@ def get_empty_error( return deserialized def get_no_model_error( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get empty error form server diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_redirects.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_redirects.py index 4ad2975375112..ac3da64a466cd 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_redirects.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_redirects.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head300( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 300 status code and redirect to /http/success/200 @@ -72,7 +72,7 @@ def head300( return client_raw_response def get300( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 300 status code and redirect to /http/success/200 @@ -121,7 +121,7 @@ def get300( return deserialized def head301( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 301 status code and redirect to /http/success/200 @@ -161,7 +161,7 @@ def head301( return client_raw_response def get301( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 301 status code and redirect to /http/success/200 @@ -201,7 +201,7 @@ def get301( return client_raw_response def put301( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put true Boolean value in request returns 301. This request should not be automatically redirected, but should return the received 301 @@ -252,7 +252,7 @@ def put301( return client_raw_response def head302( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 302 status code and redirect to /http/success/200 @@ -292,7 +292,7 @@ def head302( return client_raw_response def get302( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 302 status code and redirect to /http/success/200 @@ -332,7 +332,7 @@ def get302( return client_raw_response def patch302( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Patch true Boolean value in request returns 302. This request should not be automatically redirected, but should return the received 302 @@ -383,7 +383,7 @@ def patch302( return client_raw_response def post303( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post true Boolean value in request returns 303. This request should be automatically redirected usign a get, ultimately returning a 200 @@ -434,7 +434,7 @@ def post303( return client_raw_response def head307( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Redirect with 307, resulting in a 200 success @@ -474,7 +474,7 @@ def head307( return client_raw_response def get307( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Redirect get with 307, resulting in a 200 success @@ -514,7 +514,7 @@ def get307( return client_raw_response def put307( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put redirected with 307, resulting in a 200 after redirect @@ -563,7 +563,7 @@ def put307( return client_raw_response def patch307( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Patch redirected with 307, resulting in a 200 after redirect @@ -612,7 +612,7 @@ def patch307( return client_raw_response def post307( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post redirected with 307, resulting in a 200 after redirect @@ -661,7 +661,7 @@ def post307( return client_raw_response def delete307( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Delete redirected with 307, resulting in a 200 after redirect diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_retry.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_retry.py index 0356348b5f2d2..599a89f87926c 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_retry.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_retry.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head408( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 408 status code, then 200 after retry @@ -69,7 +69,7 @@ def head408( return client_raw_response def put500( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 500 status code, then 200 after retry @@ -115,7 +115,7 @@ def put500( return client_raw_response def patch500( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 500 status code, then 200 after retry @@ -161,7 +161,7 @@ def patch500( return client_raw_response def get502( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 502 status code, then 200 after retry @@ -198,7 +198,7 @@ def get502( return client_raw_response def post503( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 503 status code, then 200 after retry @@ -244,7 +244,7 @@ def post503( return client_raw_response def delete503( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 503 status code, then 200 after retry @@ -290,7 +290,7 @@ def delete503( return client_raw_response def put504( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 504 status code, then 200 after retry @@ -336,7 +336,7 @@ def put504( return client_raw_response def patch504( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 504 status code, then 200 after retry diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_server_failure.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_server_failure.py index 761dead10b8e7..94181adb6171f 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_server_failure.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_server_failure.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head501( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 501 status code - should be represented in the client as an error @@ -70,7 +70,7 @@ def head501( return client_raw_response def get501( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 501 status code - should be represented in the client as an error @@ -108,7 +108,7 @@ def get501( return client_raw_response def post505( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 505 status code - should be represented in the client as an error @@ -155,7 +155,7 @@ def post505( return client_raw_response def delete505( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Return 505 status code - should be represented in the client as an error diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_success.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_success.py index 1334f8b0c28a5..b5ff9b7873ae1 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_success.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/http_success.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def head200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 200 status code if successful @@ -69,7 +69,7 @@ def head200( return client_raw_response def get200( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get 200 success @@ -113,7 +113,7 @@ def get200( return deserialized def put200( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put boolean value true returning 200 success @@ -159,7 +159,7 @@ def put200( return client_raw_response def patch200( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Patch true Boolean value in request returning 200 @@ -205,7 +205,7 @@ def patch200( return client_raw_response def post200( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post bollean value true in request that returns a 200 @@ -251,7 +251,7 @@ def post200( return client_raw_response def delete200( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Delete simple boolean value true returns 200 @@ -297,7 +297,7 @@ def delete200( return client_raw_response def put201( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put true Boolean value in request returns 201 @@ -343,7 +343,7 @@ def put201( return client_raw_response def post201( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post true Boolean value in request returns 201 (Created) @@ -389,7 +389,7 @@ def post201( return client_raw_response def put202( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put true Boolean value in request returns 202 (Accepted) @@ -435,7 +435,7 @@ def put202( return client_raw_response def patch202( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Patch true Boolean value in request returns 202 @@ -481,7 +481,7 @@ def patch202( return client_raw_response def post202( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post true Boolean value in request returns 202 (Accepted) @@ -527,7 +527,7 @@ def post202( return client_raw_response def delete202( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Delete true Boolean value in request returns 202 (accepted) @@ -573,7 +573,7 @@ def delete202( return client_raw_response def head204( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 204 status code if successful @@ -610,7 +610,7 @@ def head204( return client_raw_response def put204( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Put true Boolean value in request returns 204 (no content) @@ -656,7 +656,7 @@ def put204( return client_raw_response def patch204( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Patch true Boolean value in request returns 204 (no content) @@ -702,7 +702,7 @@ def patch204( return client_raw_response def post204( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Post true Boolean value in request returns 204 (no content) @@ -748,7 +748,7 @@ def post204( return client_raw_response def delete204( - self, boolean_value=None, custom_headers={}, raw=False, **operation_config): + self, boolean_value=None, custom_headers=None, raw=False, **operation_config): """ Delete true Boolean value in request returns 204 (no content) @@ -794,7 +794,7 @@ def delete204( return client_raw_response def head404( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Return 404 status code diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/multiple_responses.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/multiple_responses.py index 04a9b92e59fa6..486c5e5fbf36e 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/multiple_responses.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Http/autoresthttpinfrastructuretestservice/operations/multiple_responses.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get200_model204_no_model_default_error200_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'statusCode': '200'} @@ -77,7 +77,7 @@ def get200_model204_no_model_default_error200_valid( return deserialized def get200_model204_no_model_default_error204_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 204 response with no payload @@ -121,7 +121,7 @@ def get200_model204_no_model_default_error204_valid( return deserialized def get200_model204_no_model_default_error201_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 201 response with valid payload: {'statusCode': '201'} @@ -165,7 +165,7 @@ def get200_model204_no_model_default_error201_invalid( return deserialized def get200_model204_no_model_default_error202_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 202 response with no payload: @@ -209,7 +209,7 @@ def get200_model204_no_model_default_error202_none( return deserialized def get200_model204_no_model_default_error400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'} @@ -254,7 +254,7 @@ def get200_model204_no_model_default_error400_valid( return deserialized def get200_model201_model_default_error200_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'statusCode': '200'} @@ -300,7 +300,7 @@ def get200_model201_model_default_error200_valid( return deserialized def get200_model201_model_default_error201_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 201 response with valid payload: {'statusCode': '201', 'textStatusCode': 'Created'} @@ -347,7 +347,7 @@ def get200_model201_model_default_error201_valid( return deserialized def get200_model201_model_default_error400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid payload: {'code': '400', 'message': 'client error'} @@ -394,7 +394,7 @@ def get200_model201_model_default_error400_valid( return deserialized def get200_model_a201_model_c404_model_ddefault_error200_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'statusCode': '200'} @@ -442,7 +442,7 @@ def get200_model_a201_model_c404_model_ddefault_error200_valid( return deserialized def get200_model_a201_model_c404_model_ddefault_error201_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'httpCode': '201'} @@ -490,7 +490,7 @@ def get200_model_a201_model_c404_model_ddefault_error201_valid( return deserialized def get200_model_a201_model_c404_model_ddefault_error404_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'httpStatusCode': '404'} @@ -538,7 +538,7 @@ def get200_model_a201_model_c404_model_ddefault_error404_valid( return deserialized def get200_model_a201_model_c404_model_ddefault_error400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid payload: {'code': '400', 'message': 'client error'} @@ -587,7 +587,7 @@ def get200_model_a201_model_c404_model_ddefault_error400_valid( return deserialized def get202_none204_none_default_error202_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 202 response with no payload @@ -624,7 +624,7 @@ def get202_none204_none_default_error202_none( return client_raw_response def get202_none204_none_default_error204_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 204 response with no payload @@ -661,7 +661,7 @@ def get202_none204_none_default_error204_none( return client_raw_response def get202_none204_none_default_error400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid payload: {'code': '400', 'message': 'client error'} @@ -699,7 +699,7 @@ def get202_none204_none_default_error400_valid( return client_raw_response def get202_none204_none_default_none202_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 202 response with an unexpected payload {'property': 'value'} @@ -736,7 +736,7 @@ def get202_none204_none_default_none202_invalid( return client_raw_response def get202_none204_none_default_none204_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 204 response with no payload @@ -773,7 +773,7 @@ def get202_none204_none_default_none204_none( return client_raw_response def get202_none204_none_default_none400_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with no payload @@ -810,7 +810,7 @@ def get202_none204_none_default_none400_none( return client_raw_response def get202_none204_none_default_none400_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with an unexpected payload {'property': 'value'} @@ -847,7 +847,7 @@ def get202_none204_none_default_none400_invalid( return client_raw_response def get_default_model_a200_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with valid payload: {'statusCode': '200'} @@ -884,7 +884,7 @@ def get_default_model_a200_valid( return client_raw_response def get_default_model_a200_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with no payload @@ -921,7 +921,7 @@ def get_default_model_a200_none( return client_raw_response def get_default_model_a400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid payload: {'statusCode': '400'} @@ -958,7 +958,7 @@ def get_default_model_a400_valid( return client_raw_response def get_default_model_a400_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with no payload @@ -995,7 +995,7 @@ def get_default_model_a400_none( return client_raw_response def get_default_none200_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with invalid payload: {'statusCode': '200'} @@ -1032,7 +1032,7 @@ def get_default_none200_invalid( return client_raw_response def get_default_none200_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with no payload @@ -1069,7 +1069,7 @@ def get_default_none200_none( return client_raw_response def get_default_none400_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with valid payload: {'statusCode': '400'} @@ -1106,7 +1106,7 @@ def get_default_none400_invalid( return client_raw_response def get_default_none400_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with no payload @@ -1143,7 +1143,7 @@ def get_default_none400_none( return client_raw_response def get200_model_a200_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with no payload, when a payload is expected - client should return a null object of thde type for model A @@ -1188,7 +1188,7 @@ def get200_model_a200_none( return deserialized def get200_model_a200_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with payload {'statusCode': '200'} @@ -1232,7 +1232,7 @@ def get200_model_a200_valid( return deserialized def get200_model_a200_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with invalid payload {'statusCodeInvalid': '200'} @@ -1276,7 +1276,7 @@ def get200_model_a200_invalid( return deserialized def get200_model_a400_none( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 400 response with no payload client should treat as an http error with no error model @@ -1321,7 +1321,7 @@ def get200_model_a400_none( return deserialized def get200_model_a400_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with payload {'statusCode': '400'} @@ -1365,7 +1365,7 @@ def get200_model_a400_valid( return deserialized def get200_model_a400_invalid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 200 response with invalid payload {'statusCodeInvalid': '400'} @@ -1409,7 +1409,7 @@ def get200_model_a400_invalid( return deserialized def get200_model_a202_valid( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Send a 202 response with payload {'statusCode': '202'} diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/__init__.py index a81829bba4a6a..f01b0f4d27100 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService, AutoRestResourceFlatteningTestServiceConfiguration +from .auto_rest_resource_flattening_test_service import AutoRestResourceFlatteningTestService from .version import VERSION -__all__ = [ - 'AutoRestResourceFlatteningTestService', - 'AutoRestResourceFlatteningTestServiceConfiguration' -] +__all__ = ['AutoRestResourceFlatteningTestService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py index b0a90b0981ec1..77be907a69467 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/auto_rest_resource_flattening_test_service.py @@ -39,22 +39,26 @@ def __init__( class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest - :param config: Configuration for client. - :type config: AutoRestResourceFlatteningTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestResourceFlatteningTestServiceConfiguration + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestResourceFlatteningTestServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def put_array( - self, resource_array=None, custom_headers={}, raw=False, **operation_config): + self, resource_array=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as an Array @@ -101,7 +105,7 @@ def put_array( return client_raw_response def get_array( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as an Array @@ -146,7 +150,7 @@ def get_array( return deserialized def put_dictionary( - self, resource_dictionary=None, custom_headers={}, raw=False, **operation_config): + self, resource_dictionary=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as a Dictionary @@ -192,7 +196,7 @@ def put_dictionary( return client_raw_response def get_dictionary( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as a Dictionary @@ -236,7 +240,7 @@ def get_dictionary( return deserialized def put_resource_collection( - self, resource_complex_object=None, custom_headers={}, raw=False, **operation_config): + self, resource_complex_object=None, custom_headers=None, raw=False, **operation_config): """ Put External Resource as a ResourceCollection @@ -284,7 +288,7 @@ def put_resource_collection( return client_raw_response def get_resource_collection( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get External Resource as a ResourceCollection @@ -329,7 +333,7 @@ def get_resource_collection( return deserialized def put_simple_product( - self, simple_body_product=None, custom_headers={}, raw=False, **operation_config): + self, simple_body_product=None, custom_headers=None, raw=False, **operation_config): """ Put Simple Product with client flattening true on the model @@ -384,7 +388,7 @@ def put_simple_product( return deserialized def post_flattened_simple_product( - self, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None, custom_headers={}, raw=False, **operation_config): + self, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None, custom_headers=None, raw=False, **operation_config): """ Put Flattened Simple Product with client flattening true on the parameter @@ -453,7 +457,7 @@ def post_flattened_simple_product( return deserialized def put_simple_product_with_grouping( - self, flatten_parameter_group, custom_headers={}, raw=False, **operation_config): + self, flatten_parameter_group, custom_headers=None, raw=False, **operation_config): """ Put Simple Product with client flattening true on the model 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 ef30dd1f2d039..3e66e6a883e48 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ModelFlattening/autorestresourceflatteningtestservice/models/flatten_parameter_group.py @@ -14,7 +14,7 @@ class FlattenParameterGroup(Model): """ - Additional parameters for the putSimpleProductWithGrouping operation. + Additional parameters for one or more operations :param name: Product name with value 'groupproduct' :type name: str diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/__init__.py index d7676b401a1e3..eb1fb871fdd18 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_parameter_flattening import AutoRestParameterFlattening, AutoRestParameterFlatteningConfiguration +from .auto_rest_parameter_flattening import AutoRestParameterFlattening from .version import VERSION -__all__ = [ - 'AutoRestParameterFlattening', - 'AutoRestParameterFlatteningConfiguration' -] +__all__ = ['AutoRestParameterFlattening'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/auto_rest_parameter_flattening.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/auto_rest_parameter_flattening.py index de25b7d5f0a74..b3c9a71e2c1f0 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/auto_rest_parameter_flattening.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/auto_rest_parameter_flattening.py @@ -39,21 +39,25 @@ def __init__( class AutoRestParameterFlattening(object): """Resource Flattening for AutoRest - :param config: Configuration for client. - :type config: AutoRestParameterFlatteningConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestParameterFlatteningConfiguration :ivar availability_sets: AvailabilitySets operations :vartype availability_sets: .operations.AvailabilitySets + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestParameterFlatteningConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.availability_sets = AvailabilitySets( self._client, self.config, self._serialize, self._deserialize) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/operations/availability_sets.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/operations/availability_sets.py index ec69672916dca..a45da1f5bfd72 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/operations/availability_sets.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/ParameterFlattening/autorestparameterflattening/operations/availability_sets.py @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def update( - self, resource_group_name, avset, tags, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, avset, tags, custom_headers=None, raw=False, **operation_config): """ Updates the tags for an availability set. diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/__init__.py index 8ecae208fac42..22573b1921a87 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_report_service import AutoRestReportService, AutoRestReportServiceConfiguration +from .auto_rest_report_service import AutoRestReportService from .version import VERSION -__all__ = [ - 'AutoRestReportService', - 'AutoRestReportServiceConfiguration' -] +__all__ = ['AutoRestReportService'] __version__ = VERSION diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/auto_rest_report_service.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/auto_rest_report_service.py index 333455a14a14c..caa51db50051b 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/auto_rest_report_service.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Report/autorestreportservice/auto_rest_report_service.py @@ -39,22 +39,26 @@ def __init__( class AutoRestReportService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestReportServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestReportServiceConfiguration + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestReportServiceConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def get_report( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Get test coverage report diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/__init__.py index 260d9c07a819d..23a6ed29f55e3 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_required_optional_test_service import AutoRestRequiredOptionalTestService, AutoRestRequiredOptionalTestServiceConfiguration +from .auto_rest_required_optional_test_service import AutoRestRequiredOptionalTestService from .version import VERSION -__all__ = [ - 'AutoRestRequiredOptionalTestService', - 'AutoRestRequiredOptionalTestServiceConfiguration' -] +__all__ = ['AutoRestRequiredOptionalTestService'] __version__ = VERSION 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 7dcce131d92ad..c22c57d10fdbe 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 @@ -58,24 +58,34 @@ def __init__( class AutoRestRequiredOptionalTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestRequiredOptionalTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestRequiredOptionalTestServiceConfiguration :ivar implicit: Implicit operations :vartype implicit: .operations.Implicit :ivar explicit: Explicit operations :vartype explicit: .operations.Explicit + + :param required_global_path: number of items to skip + :type required_global_path: str + :param required_global_query: number of items to skip + :type required_global_query: str + :param optional_global_query: number of items to skip + :type optional_global_query: int + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, required_global_path, required_global_query, optional_global_query=None, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestRequiredOptionalTestServiceConfiguration(required_global_path, required_global_query, optional_global_query, base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.implicit = Implicit( self._client, self.config, self._serialize, self._deserialize) self.explicit = Explicit( diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/explicit.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/explicit.py index 4f56d1d617c05..359feac46339a 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/explicit.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/explicit.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def post_required_integer_parameter( - self, body_parameter, custom_headers={}, raw=False, **operation_config): + self, body_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required integer. Please put null and the client library should throw before the request is sent. @@ -77,7 +77,7 @@ def post_required_integer_parameter( return client_raw_response def post_optional_integer_parameter( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional integer. Please put null. @@ -123,7 +123,7 @@ def post_optional_integer_parameter( return client_raw_response def post_required_integer_property( - self, value, custom_headers={}, raw=False, **operation_config): + self, value, custom_headers=None, raw=False, **operation_config): """ Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the client library should throw before the request @@ -171,7 +171,7 @@ def post_required_integer_property( return client_raw_response def post_optional_integer_property( - self, value=None, custom_headers={}, raw=False, **operation_config): + self, value=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. @@ -222,7 +222,7 @@ def post_optional_integer_property( return client_raw_response def post_required_integer_header( - self, header_parameter, custom_headers={}, raw=False, **operation_config): + self, header_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required integer. Please put a header 'headerParameter' => null and the client library should throw before @@ -265,7 +265,7 @@ def post_required_integer_header( return client_raw_response def post_optional_integer_header( - self, header_parameter=None, custom_headers={}, raw=False, **operation_config): + self, header_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional integer. Please put a header 'headerParameter' => null. @@ -307,7 +307,7 @@ def post_optional_integer_header( return client_raw_response def post_required_string_parameter( - self, body_parameter, custom_headers={}, raw=False, **operation_config): + self, body_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required string. Please put null and the client library should throw before the request is sent. @@ -352,7 +352,7 @@ def post_required_string_parameter( return client_raw_response def post_optional_string_parameter( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional string. Please put null. @@ -398,7 +398,7 @@ def post_optional_string_parameter( return client_raw_response def post_required_string_property( - self, value, custom_headers={}, raw=False, **operation_config): + self, value, custom_headers=None, raw=False, **operation_config): """ Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the client library should throw before the @@ -446,7 +446,7 @@ def post_required_string_property( return client_raw_response def post_optional_string_property( - self, value=None, custom_headers={}, raw=False, **operation_config): + self, value=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. @@ -497,7 +497,7 @@ def post_optional_string_property( return client_raw_response def post_required_string_header( - self, header_parameter, custom_headers={}, raw=False, **operation_config): + self, header_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required string. Please put a header 'headerParameter' => null and the client library should throw before the request is @@ -540,7 +540,7 @@ def post_required_string_header( return client_raw_response def post_optional_string_header( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional string. Please put a header 'headerParameter' => null. @@ -582,7 +582,7 @@ def post_optional_string_header( return client_raw_response def post_required_class_parameter( - self, body_parameter, custom_headers={}, raw=False, **operation_config): + self, body_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required complex object. Please put null and the client library should throw before the request is sent. @@ -628,7 +628,7 @@ def post_required_class_parameter( return client_raw_response def post_optional_class_parameter( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional complex object. Please put null. @@ -675,7 +675,7 @@ def post_optional_class_parameter( return client_raw_response def post_required_class_property( - self, value, custom_headers={}, raw=False, **operation_config): + self, value, custom_headers=None, raw=False, **operation_config): """ Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null and the client library should throw @@ -724,7 +724,7 @@ def post_required_class_property( return client_raw_response def post_optional_class_property( - self, value=None, custom_headers={}, raw=False, **operation_config): + self, value=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. @@ -776,7 +776,7 @@ def post_optional_class_property( return client_raw_response def post_required_array_parameter( - self, body_parameter, custom_headers={}, raw=False, **operation_config): + self, body_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required array. Please put null and the client library should throw before the request is sent. @@ -821,7 +821,7 @@ def post_required_array_parameter( return client_raw_response def post_optional_array_parameter( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional array. Please put null. @@ -867,7 +867,7 @@ def post_optional_array_parameter( return client_raw_response def post_required_array_property( - self, value, custom_headers={}, raw=False, **operation_config): + self, value, custom_headers=None, raw=False, **operation_config): """ Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the client library should throw before the request @@ -915,7 +915,7 @@ def post_required_array_property( return client_raw_response def post_optional_array_property( - self, value=None, custom_headers={}, raw=False, **operation_config): + self, value=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. @@ -966,7 +966,7 @@ def post_optional_array_property( return client_raw_response def post_required_array_header( - self, header_parameter, custom_headers={}, raw=False, **operation_config): + self, header_parameter, custom_headers=None, raw=False, **operation_config): """ Test explicitly required array. Please put a header 'headerParameter' => null and the client library should throw before the request is @@ -1009,7 +1009,7 @@ def post_required_array_header( return client_raw_response def post_optional_array_header( - self, header_parameter=None, custom_headers={}, raw=False, **operation_config): + self, header_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test explicitly optional integer. Please put a header 'headerParameter' => null. diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/implicit.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/implicit.py index cddb3b124e652..91919cfd00ca8 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/implicit.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/RequiredOptional/autorestrequiredoptionaltestservice/operations/implicit.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_required_path( - self, path_parameter, custom_headers={}, raw=False, **operation_config): + self, path_parameter, custom_headers=None, raw=False, **operation_config): """ Test implicitly required path parameter @@ -76,7 +76,7 @@ def get_required_path( return client_raw_response def put_optional_query( - self, query_parameter=None, custom_headers={}, raw=False, **operation_config): + self, query_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test implicitly optional query parameter @@ -117,7 +117,7 @@ def put_optional_query( return client_raw_response def put_optional_header( - self, query_parameter=None, custom_headers={}, raw=False, **operation_config): + self, query_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test implicitly optional header parameter @@ -158,7 +158,7 @@ def put_optional_header( return client_raw_response def put_optional_body( - self, body_parameter=None, custom_headers={}, raw=False, **operation_config): + self, body_parameter=None, custom_headers=None, raw=False, **operation_config): """ Test implicitly optional body parameter @@ -204,7 +204,7 @@ def put_optional_body( return client_raw_response def get_required_global_path( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Test implicitly required path parameter @@ -246,7 +246,7 @@ def get_required_global_path( return client_raw_response def get_required_global_query( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Test implicitly required query parameter @@ -285,7 +285,7 @@ def get_required_global_query( return client_raw_response def get_optional_global_query( - self, custom_headers={}, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """ Test implicitly optional query parameter diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/__init__.py index fc6d1efe1f583..523c4f1401789 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_url_test_service import AutoRestUrlTestService, AutoRestUrlTestServiceConfiguration +from .auto_rest_url_test_service import AutoRestUrlTestService from .version import VERSION -__all__ = [ - 'AutoRestUrlTestService', - 'AutoRestUrlTestServiceConfiguration' -] +__all__ = ['AutoRestUrlTestService'] __version__ = VERSION 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 34efde192fd6b..a6d660a1c267a 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 @@ -55,8 +55,8 @@ def __init__( class AutoRestUrlTestService(object): """Test Infrastructure for AutoRest - :param config: Configuration for client. - :type config: AutoRestUrlTestServiceConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestUrlTestServiceConfiguration :ivar paths: Paths operations :vartype paths: .operations.Paths @@ -64,17 +64,26 @@ class AutoRestUrlTestService(object): :vartype queries: .operations.Queries :ivar path_items: PathItems operations :vartype path_items: .operations.PathItems + + :param global_string_path: A string value 'globalItemStringPath' that + appears in the path + :type global_string_path: str + :param global_string_query: should contain value null + :type global_string_query: str + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, global_string_path, global_string_query=None, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestUrlTestServiceConfiguration(global_string_path, global_string_query, base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.paths = Paths( self._client, self.config, self._serialize, self._deserialize) self.queries = Queries( diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/path_items.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/path_items.py index 52f1f2feba029..d3f3e72c6ea35 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/path_items.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/path_items.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_all_with_values( - self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers={}, raw=False, **operation_config): + self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers=None, raw=False, **operation_config): """ send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', @@ -96,7 +96,7 @@ def get_all_with_values( return client_raw_response def get_global_query_null( - self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers={}, raw=False, **operation_config): + self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers=None, raw=False, **operation_config): """ send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', @@ -159,7 +159,7 @@ def get_global_query_null( return client_raw_response def get_global_and_local_query_null( - self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers={}, raw=False, **operation_config): + self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers=None, raw=False, **operation_config): """ send globalStringPath=globalStringPath, pathItemStringPath='pathItemStringPath', @@ -221,7 +221,7 @@ def get_global_and_local_query_null( return client_raw_response def get_local_path_item_query_null( - self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers={}, raw=False, **operation_config): + self, local_string_path, path_item_string_path, local_string_query=None, path_item_string_query=None, custom_headers=None, raw=False, **operation_config): """ send globalStringPath='globalStringPath', pathItemStringPath='pathItemStringPath', 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 c419d607826a2..c5e497e11e4f7 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 @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_boolean_true( - self, bool_path=False, custom_headers={}, raw=False, **operation_config): + self, bool_path=False, custom_headers=None, raw=False, **operation_config): """ Get true Boolean value on path @@ -75,7 +75,7 @@ def get_boolean_true( return client_raw_response def get_boolean_false( - self, bool_path=False, custom_headers={}, raw=False, **operation_config): + self, bool_path=False, custom_headers=None, raw=False, **operation_config): """ Get false Boolean value on path @@ -118,7 +118,7 @@ def get_boolean_false( return client_raw_response def get_int_one_million( - self, int_path=1000000, custom_headers={}, raw=False, **operation_config): + self, int_path=1000000, custom_headers=None, raw=False, **operation_config): """ Get '1000000' integer value @@ -161,7 +161,7 @@ def get_int_one_million( return client_raw_response def get_int_negative_one_million( - self, int_path=-1000000, custom_headers={}, raw=False, **operation_config): + self, int_path=-1000000, custom_headers=None, raw=False, **operation_config): """ Get '-1000000' integer value @@ -204,7 +204,7 @@ def get_int_negative_one_million( return client_raw_response def get_ten_billion( - self, long_path=10000000000, custom_headers={}, raw=False, **operation_config): + self, long_path=10000000000, custom_headers=None, raw=False, **operation_config): """ Get '10000000000' 64 bit integer value @@ -247,7 +247,7 @@ def get_ten_billion( return client_raw_response def get_negative_ten_billion( - self, long_path=-10000000000, custom_headers={}, raw=False, **operation_config): + self, long_path=-10000000000, custom_headers=None, raw=False, **operation_config): """ Get '-10000000000' 64 bit integer value @@ -290,7 +290,7 @@ def get_negative_ten_billion( return client_raw_response def float_scientific_positive( - self, float_path=1.034E+20, custom_headers={}, raw=False, **operation_config): + self, float_path=1.034E+20, custom_headers=None, raw=False, **operation_config): """ Get '1.034E+20' numeric value @@ -333,7 +333,7 @@ def float_scientific_positive( return client_raw_response def float_scientific_negative( - self, float_path=-1.034E-20, custom_headers={}, raw=False, **operation_config): + self, float_path=-1.034E-20, custom_headers=None, raw=False, **operation_config): """ Get '-1.034E-20' numeric value @@ -376,7 +376,7 @@ def float_scientific_negative( return client_raw_response def double_decimal_positive( - self, double_path=9999999.999, custom_headers={}, raw=False, **operation_config): + self, double_path=9999999.999, custom_headers=None, raw=False, **operation_config): """ Get '9999999.999' numeric value @@ -419,7 +419,7 @@ def double_decimal_positive( return client_raw_response def double_decimal_negative( - self, double_path=-9999999.999, custom_headers={}, raw=False, **operation_config): + self, double_path=-9999999.999, custom_headers=None, raw=False, **operation_config): """ Get '-9999999.999' numeric value @@ -462,7 +462,7 @@ def double_decimal_negative( return client_raw_response def string_unicode( - self, string_path="啊齄丂狛狜隣郎隣兀﨩", custom_headers={}, raw=False, **operation_config): + self, string_path="啊齄丂狛狜隣郎隣兀﨩", custom_headers=None, raw=False, **operation_config): """ Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value @@ -505,7 +505,7 @@ def string_unicode( return client_raw_response def string_url_encoded( - self, string_path="begin!*'();:@ &=+$,/?#[]end", custom_headers={}, raw=False, **operation_config): + self, string_path="begin!*'();:@ &=+$,/?#[]end", custom_headers=None, raw=False, **operation_config): """ Get 'begin!*'();:@ &=+$,/?#[]end @@ -549,7 +549,7 @@ def string_url_encoded( return client_raw_response def string_empty( - self, string_path="", custom_headers={}, raw=False, **operation_config): + self, string_path="", custom_headers=None, raw=False, **operation_config): """ Get '' @@ -592,7 +592,7 @@ def string_empty( return client_raw_response def string_null( - self, string_path, custom_headers={}, raw=False, **operation_config): + self, string_path, custom_headers=None, raw=False, **operation_config): """ Get null (should throw) @@ -635,13 +635,14 @@ def string_null( return client_raw_response def enum_valid( - self, enum_path, custom_headers={}, raw=False, **operation_config): + self, enum_path, custom_headers=None, raw=False, **operation_config): """ Get using uri with 'green color' in path parameter :param enum_path: send the value green. Possible values include: 'red color', 'green color', 'blue color' - :type enum_path: str + :type enum_path: str or :class:`UriColor + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -679,14 +680,15 @@ def enum_valid( return client_raw_response def enum_null( - self, enum_path, custom_headers={}, raw=False, **operation_config): + self, enum_path, custom_headers=None, raw=False, **operation_config): """ Get null (should throw on the client before the request is sent on wire) :param enum_path: send null should throw. Possible values include: 'red color', 'green color', 'blue color' - :type enum_path: str + :type enum_path: str or :class:`UriColor + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -724,7 +726,7 @@ def enum_null( return client_raw_response def byte_multi_byte( - self, byte_path, custom_headers={}, raw=False, **operation_config): + self, byte_path, custom_headers=None, raw=False, **operation_config): """ Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array @@ -768,7 +770,7 @@ def byte_multi_byte( return client_raw_response def byte_empty( - self, byte_path=bytearray("", encoding="utf-8"), custom_headers={}, raw=False, **operation_config): + self, byte_path=bytearray("", encoding="utf-8"), custom_headers=None, raw=False, **operation_config): """ Get '' as byte array @@ -811,7 +813,7 @@ def byte_empty( return client_raw_response def byte_null( - self, byte_path, custom_headers={}, raw=False, **operation_config): + self, byte_path, custom_headers=None, raw=False, **operation_config): """ Get null as byte array (should throw) @@ -854,7 +856,7 @@ def byte_null( return client_raw_response def date_valid( - self, date_path, custom_headers={}, raw=False, **operation_config): + self, date_path, custom_headers=None, raw=False, **operation_config): """ Get '2012-01-01' as date @@ -897,7 +899,7 @@ def date_valid( return client_raw_response def date_null( - self, date_path, custom_headers={}, raw=False, **operation_config): + self, date_path, custom_headers=None, raw=False, **operation_config): """ Get null as date - this should throw or be unusable on the client side, depending on date representation @@ -941,7 +943,7 @@ def date_null( return client_raw_response def date_time_valid( - self, date_time_path, custom_headers={}, raw=False, **operation_config): + self, date_time_path, custom_headers=None, raw=False, **operation_config): """ Get '2012-01-01T01:01:01Z' as date-time @@ -984,7 +986,7 @@ def date_time_valid( return client_raw_response def date_time_null( - self, date_time_path, custom_headers={}, raw=False, **operation_config): + self, date_time_path, custom_headers=None, raw=False, **operation_config): """ Get null as date-time, should be disallowed or throw depending on representation of date-time @@ -1028,12 +1030,12 @@ def date_time_null( return client_raw_response def base64_url( - self, base64_url_path, custom_headers={}, raw=False, **operation_config): + self, base64_url_path, custom_headers=None, raw=False, **operation_config): """ Get 'lorem' encoded value as 'bG9yZW0' (base64url) :param base64_url_path: base64url encoded value - :type base64_url_path: str + :type base64_url_path: bytes :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1046,7 +1048,7 @@ def base64_url( # Construct URL url = '/paths/string/bG9yZW0/{base64UrlPath}' path_format_arguments = { - 'base64UrlPath': self._serialize.url("base64_url_path", base64_url_path, 'str') + 'base64UrlPath': self._serialize.url("base64_url_path", base64_url_path, 'base64') } url = self._client.format_url(url, **path_format_arguments) @@ -1071,7 +1073,7 @@ def base64_url( return client_raw_response def array_csv_in_path( - self, array_path, custom_headers={}, raw=False, **operation_config): + self, array_path, custom_headers=None, raw=False, **operation_config): """ Get an array of string ['ArrayPath1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the csv-array format @@ -1116,12 +1118,12 @@ def array_csv_in_path( return client_raw_response def unix_time_url( - self, unix_time_url_path, custom_headers={}, raw=False, **operation_config): + self, unix_time_url_path, custom_headers=None, raw=False, **operation_config): """ Get the date 2016-04-13 encoded value as '1460505600' (Unix time) :param unix_time_url_path: Unix time encoded value - :type unix_time_url_path: long + :type unix_time_url_path: datetime :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1134,7 +1136,7 @@ def unix_time_url( # Construct URL url = '/paths/int/1460505600/{unixTimeUrlPath}' path_format_arguments = { - 'unixTimeUrlPath': self._serialize.url("unix_time_url_path", unix_time_url_path, 'long') + 'unixTimeUrlPath': self._serialize.url("unix_time_url_path", unix_time_url_path, 'unix-time') } url = self._client.format_url(url, **path_format_arguments) diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/queries.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/queries.py index 4503b7fc304ec..309ef289b50d2 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/queries.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Url/autoresturltestservice/operations/queries.py @@ -32,7 +32,7 @@ def __init__(self, client, config, serializer, deserializer): self.config = config def get_boolean_true( - self, bool_query=False, custom_headers={}, raw=False, **operation_config): + self, bool_query=False, custom_headers=None, raw=False, **operation_config): """ Get true Boolean value on path @@ -72,7 +72,7 @@ def get_boolean_true( return client_raw_response def get_boolean_false( - self, bool_query=False, custom_headers={}, raw=False, **operation_config): + self, bool_query=False, custom_headers=None, raw=False, **operation_config): """ Get false Boolean value on path @@ -112,7 +112,7 @@ def get_boolean_false( return client_raw_response def get_boolean_null( - self, bool_query=None, custom_headers={}, raw=False, **operation_config): + self, bool_query=None, custom_headers=None, raw=False, **operation_config): """ Get null Boolean value on query (query string should be absent) @@ -153,7 +153,7 @@ def get_boolean_null( return client_raw_response def get_int_one_million( - self, int_query=1000000, custom_headers={}, raw=False, **operation_config): + self, int_query=1000000, custom_headers=None, raw=False, **operation_config): """ Get '1000000' integer value @@ -193,7 +193,7 @@ def get_int_one_million( return client_raw_response def get_int_negative_one_million( - self, int_query=-1000000, custom_headers={}, raw=False, **operation_config): + self, int_query=-1000000, custom_headers=None, raw=False, **operation_config): """ Get '-1000000' integer value @@ -233,7 +233,7 @@ def get_int_negative_one_million( return client_raw_response def get_int_null( - self, int_query=None, custom_headers={}, raw=False, **operation_config): + self, int_query=None, custom_headers=None, raw=False, **operation_config): """ Get null integer value (no query parameter) @@ -274,7 +274,7 @@ def get_int_null( return client_raw_response def get_ten_billion( - self, long_query=10000000000, custom_headers={}, raw=False, **operation_config): + self, long_query=10000000000, custom_headers=None, raw=False, **operation_config): """ Get '10000000000' 64 bit integer value @@ -314,7 +314,7 @@ def get_ten_billion( return client_raw_response def get_negative_ten_billion( - self, long_query=-10000000000, custom_headers={}, raw=False, **operation_config): + self, long_query=-10000000000, custom_headers=None, raw=False, **operation_config): """ Get '-10000000000' 64 bit integer value @@ -354,7 +354,7 @@ def get_negative_ten_billion( return client_raw_response def get_long_null( - self, long_query=None, custom_headers={}, raw=False, **operation_config): + self, long_query=None, custom_headers=None, raw=False, **operation_config): """ Get 'null 64 bit integer value (no query param in uri) @@ -395,7 +395,7 @@ def get_long_null( return client_raw_response def float_scientific_positive( - self, float_query=1.034E+20, custom_headers={}, raw=False, **operation_config): + self, float_query=1.034E+20, custom_headers=None, raw=False, **operation_config): """ Get '1.034E+20' numeric value @@ -435,7 +435,7 @@ def float_scientific_positive( return client_raw_response def float_scientific_negative( - self, float_query=-1.034E-20, custom_headers={}, raw=False, **operation_config): + self, float_query=-1.034E-20, custom_headers=None, raw=False, **operation_config): """ Get '-1.034E-20' numeric value @@ -475,7 +475,7 @@ def float_scientific_negative( return client_raw_response def float_null( - self, float_query=None, custom_headers={}, raw=False, **operation_config): + self, float_query=None, custom_headers=None, raw=False, **operation_config): """ Get null numeric value (no query parameter) @@ -516,7 +516,7 @@ def float_null( return client_raw_response def double_decimal_positive( - self, double_query=9999999.999, custom_headers={}, raw=False, **operation_config): + self, double_query=9999999.999, custom_headers=None, raw=False, **operation_config): """ Get '9999999.999' numeric value @@ -556,7 +556,7 @@ def double_decimal_positive( return client_raw_response def double_decimal_negative( - self, double_query=-9999999.999, custom_headers={}, raw=False, **operation_config): + self, double_query=-9999999.999, custom_headers=None, raw=False, **operation_config): """ Get '-9999999.999' numeric value @@ -596,7 +596,7 @@ def double_decimal_negative( return client_raw_response def double_null( - self, double_query=None, custom_headers={}, raw=False, **operation_config): + self, double_query=None, custom_headers=None, raw=False, **operation_config): """ Get null numeric value (no query parameter) @@ -637,7 +637,7 @@ def double_null( return client_raw_response def string_unicode( - self, string_query="啊齄丂狛狜隣郎隣兀﨩", custom_headers={}, raw=False, **operation_config): + self, string_query="啊齄丂狛狜隣郎隣兀﨩", custom_headers=None, raw=False, **operation_config): """ Get '啊齄丂狛狜隣郎隣兀﨩' multi-byte string value @@ -677,7 +677,7 @@ def string_unicode( return client_raw_response def string_url_encoded( - self, string_query="begin!*'();:@ &=+$,/?#[]end", custom_headers={}, raw=False, **operation_config): + self, string_query="begin!*'();:@ &=+$,/?#[]end", custom_headers=None, raw=False, **operation_config): """ Get 'begin!*'();:@ &=+$,/?#[]end @@ -718,7 +718,7 @@ def string_url_encoded( return client_raw_response def string_empty( - self, string_query="", custom_headers={}, raw=False, **operation_config): + self, string_query="", custom_headers=None, raw=False, **operation_config): """ Get '' @@ -758,7 +758,7 @@ def string_empty( return client_raw_response def string_null( - self, string_query=None, custom_headers={}, raw=False, **operation_config): + self, string_query=None, custom_headers=None, raw=False, **operation_config): """ Get null (no query parameter in url) @@ -799,13 +799,14 @@ def string_null( return client_raw_response def enum_valid( - self, enum_query=None, custom_headers={}, raw=False, **operation_config): + self, enum_query=None, custom_headers=None, raw=False, **operation_config): """ Get using uri with query parameter 'green color' :param enum_query: 'green color' enum value. Possible values include: 'red color', 'green color', 'blue color' - :type enum_query: str + :type enum_query: str or :class:`UriColor + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -841,13 +842,14 @@ def enum_valid( return client_raw_response def enum_null( - self, enum_query=None, custom_headers={}, raw=False, **operation_config): + self, enum_query=None, custom_headers=None, raw=False, **operation_config): """ Get null (no query parameter in url) :param enum_query: null string value. Possible values include: 'red color', 'green color', 'blue color' - :type enum_query: str + :type enum_query: str or :class:`UriColor + ` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -883,7 +885,7 @@ def enum_null( return client_raw_response def byte_multi_byte( - self, byte_query=None, custom_headers={}, raw=False, **operation_config): + self, byte_query=None, custom_headers=None, raw=False, **operation_config): """ Get '啊齄丂狛狜隣郎隣兀﨩' multibyte value as utf-8 encoded byte array @@ -925,7 +927,7 @@ def byte_multi_byte( return client_raw_response def byte_empty( - self, byte_query=bytearray("", encoding="utf-8"), custom_headers={}, raw=False, **operation_config): + self, byte_query=bytearray("", encoding="utf-8"), custom_headers=None, raw=False, **operation_config): """ Get '' as byte array @@ -965,7 +967,7 @@ def byte_empty( return client_raw_response def byte_null( - self, byte_query=None, custom_headers={}, raw=False, **operation_config): + self, byte_query=None, custom_headers=None, raw=False, **operation_config): """ Get null as byte array (no query parameters in uri) @@ -1006,7 +1008,7 @@ def byte_null( return client_raw_response def date_valid( - self, date_query, custom_headers={}, raw=False, **operation_config): + self, date_query, custom_headers=None, raw=False, **operation_config): """ Get '2012-01-01' as date @@ -1046,7 +1048,7 @@ def date_valid( return client_raw_response def date_null( - self, date_query=None, custom_headers={}, raw=False, **operation_config): + self, date_query=None, custom_headers=None, raw=False, **operation_config): """ Get null as date - this should result in no query parameters in uri @@ -1087,7 +1089,7 @@ def date_null( return client_raw_response def date_time_valid( - self, date_time_query, custom_headers={}, raw=False, **operation_config): + self, date_time_query, custom_headers=None, raw=False, **operation_config): """ Get '2012-01-01T01:01:01Z' as date-time @@ -1127,7 +1129,7 @@ def date_time_valid( return client_raw_response def date_time_null( - self, date_time_query=None, custom_headers={}, raw=False, **operation_config): + self, date_time_query=None, custom_headers=None, raw=False, **operation_config): """ Get null as date-time, should result in no query parameters in uri @@ -1168,7 +1170,7 @@ def date_time_null( return client_raw_response def array_string_csv_valid( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the csv-array format @@ -1211,7 +1213,7 @@ def array_string_csv_valid( return client_raw_response def array_string_csv_null( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get a null array of string using the csv-array format @@ -1252,7 +1254,7 @@ def array_string_csv_null( return client_raw_response def array_string_csv_empty( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get an empty array [] of string using the csv-array format @@ -1294,7 +1296,7 @@ def array_string_csv_empty( return client_raw_response def array_string_ssv_valid( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the ssv-array format @@ -1337,7 +1339,7 @@ def array_string_ssv_valid( return client_raw_response def array_string_tsv_valid( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the tsv-array format @@ -1380,7 +1382,7 @@ def array_string_tsv_valid( return client_raw_response def array_string_pipes_valid( - self, array_query=None, custom_headers={}, raw=False, **operation_config): + self, array_query=None, custom_headers=None, raw=False, **operation_config): """ Get an array of string ['ArrayQuery1', 'begin!*'();:@ &=+$,/?#[]end' , null, ''] using the pipes-array format diff --git a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/__init__.py b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/__init__.py index 202f03f0f743e..885383be0a477 100644 --- a/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/__init__.py +++ b/AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/Validation/autorestvalidationtest/__init__.py @@ -9,13 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .auto_rest_validation_test import AutoRestValidationTest, AutoRestValidationTestConfiguration +from .auto_rest_validation_test import AutoRestValidationTest from .version import VERSION -__all__ = [ - 'AutoRestValidationTest', - 'AutoRestValidationTestConfiguration' -] +__all__ = ['AutoRestValidationTest'] __version__ = VERSION 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 f9a6b88ede469..08b08680cef8a 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 @@ -55,22 +55,30 @@ def __init__( class AutoRestValidationTest(object): """Test Infrastructure for AutoRest. No server backend exists for these tests. - :param config: Configuration for client. - :type config: AutoRestValidationTestConfiguration + :ivar config: Configuration for client. + :vartype config: AutoRestValidationTestConfiguration + + :param subscription_id: Subscription ID. + :type subscription_id: str + :param api_version: Required string following pattern \\d{2}-\\d{2}-\\d{4} + :type api_version: str + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, subscription_id, api_version, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = AutoRestValidationTestConfiguration(subscription_id, api_version, base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def validation_of_method_parameters( - self, resource_group_name, id, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, id, custom_headers=None, raw=False, **operation_config): """ Validates input parameters on the method. See swagger for details. @@ -127,7 +135,7 @@ def validation_of_method_parameters( return deserialized def validation_of_body( - self, resource_group_name, id, body=None, custom_headers={}, raw=False, **operation_config): + self, resource_group_name, id, body=None, custom_headers=None, raw=False, **operation_config): """ Validates body parameters on the method. See swagger for details. @@ -194,7 +202,7 @@ def validation_of_body( return deserialized def get_with_constant_in_path( - self, constant_param="constant", custom_headers={}, raw=False, **operation_config): + self, constant_param="constant", custom_headers=None, raw=False, **operation_config): """ :param constant_param: @@ -236,7 +244,7 @@ def get_with_constant_in_path( return client_raw_response def post_with_constant_in_body( - self, constant_param="constant", body=None, custom_headers={}, raw=False, **operation_config): + self, constant_param="constant", body=None, custom_headers=None, raw=False, **operation_config): """ :param constant_param: 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 65d49c5d12e17..a8e00da0b0808 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 @@ -39,7 +39,8 @@ class Product(Model): :vartype const_string: str :param const_string_as_enum: Constant string as Enum. Possible values include: 'constant_string_as_enum' - :type const_string_as_enum: str + :type const_string_as_enum: str or :class:`EnumConst + ` """ _validation = { diff --git a/AutoRest/Generators/Python/Python/ClientModelExtensions.cs b/AutoRest/Generators/Python/Python/ClientModelExtensions.cs index d43e67525c2d8..131b0ef8a7941 100644 --- a/AutoRest/Generators/Python/Python/ClientModelExtensions.cs +++ b/AutoRest/Generators/Python/Python/ClientModelExtensions.cs @@ -147,6 +147,22 @@ public static string ToPythonRuntimeTypeString(this IType type) { return "duration"; } + + if (known.Type == KnownPrimaryType.UnixTime) + { + return "unix-time"; + } + + if (known.Type == KnownPrimaryType.Base64Url) + { + return "base64"; + } + } + + var enumType = type as EnumType; + if (enumType != null && enumType.ModelAsString) + { + return "str"; } var sequenceType = type as SequenceType; @@ -246,7 +262,9 @@ public static string GetPythonSerializationType(IType type) { { KnownPrimaryType.DateTime, "iso-8601" }, { KnownPrimaryType.DateTimeRfc1123, "rfc-1123" }, - { KnownPrimaryType.TimeSpan, "duration" } + { KnownPrimaryType.TimeSpan, "duration" }, + { KnownPrimaryType.UnixTime, "unix-time" }, + { KnownPrimaryType.Base64Url, "base64" } }; PrimaryType primaryType = type as PrimaryType; if (primaryType != null) @@ -295,6 +313,12 @@ public static string GetPythonSerializationType(IType type) return "{" + innerTypeName + "}"; } + EnumType enumType = type as EnumType; + if (enumType != null && enumType.ModelAsString) + { + return "str"; + } + // CompositeType or EnumType return type.Name; } diff --git a/AutoRest/Generators/Python/Python/PythonCodeNamer.cs b/AutoRest/Generators/Python/Python/PythonCodeNamer.cs index 11ae0801acce4..53cbd4e2d938f 100644 --- a/AutoRest/Generators/Python/Python/PythonCodeNamer.cs +++ b/AutoRest/Generators/Python/Python/PythonCodeNamer.cs @@ -254,7 +254,7 @@ public override IType NormalizeTypeReference(IType type) return null; } var enumType = type as EnumType; - if (enumType != null && enumType.Name.Length == 0 && enumType.ModelAsString) + if (enumType != null && enumType.Name.Length == 0) { type = new PrimaryType(KnownPrimaryType.String) { @@ -301,6 +301,7 @@ private IType NormalizeEnumType(EnumType enumType) { enumType.Values[i].Name = GetEnumMemberName(enumType.Values[i].Name); } + return enumType; } @@ -326,7 +327,7 @@ private static IType NormalizePrimaryType(PrimaryType primaryType) if (primaryType.Type == KnownPrimaryType.Base64Url) { - primaryType.Name = "str"; + primaryType.Name = "bytes"; } else if (primaryType.Type == KnownPrimaryType.Boolean) { @@ -378,7 +379,7 @@ private static IType NormalizePrimaryType(PrimaryType primaryType) } else if (primaryType.Type == KnownPrimaryType.UnixTime) { - primaryType.Name = "long"; + primaryType.Name = "datetime"; } else if (primaryType.Type == KnownPrimaryType.Object) // Revisit here { diff --git a/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs index ee71dc5b08b4d..2c3a051d9c93d 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/MethodTemplateModel.cs @@ -181,7 +181,7 @@ public virtual string MethodParameterDeclaration(bool addCustomHeaderParameters) if (addCustomHeaderParameters) { - declarations.Add("custom_headers={}"); + declarations.Add("custom_headers=None"); } declarations.Add("raw=False"); @@ -436,7 +436,8 @@ protected void AddHeaderDictionary(IndentedStringBuilder builder, CompositeType foreach (var prop in headersType.Properties) { - if (this.ServiceClient.EnumTypes.Contains(prop.Type)) + var enumType = prop.Type as EnumType; + if (this.ServiceClient.EnumTypes.Contains(prop.Type) && !enumType.ModelAsString) { builder.AppendLine(String.Format(CultureInfo.InvariantCulture, "'{0}': models.{1},", prop.SerializedName, prop.Type.ToPythonRuntimeTypeString())); } @@ -555,9 +556,10 @@ public string GetDocumentationType(IType type) } string result = "object"; - + var modelNamespace = ServiceClient.Name.ToPythonCase().Replace("_", ""); var primaryType = type as PrimaryType; var listType = type as SequenceType; + var enumType = type as EnumType; if (primaryType != null) { if (primaryType.Type == KnownPrimaryType.Stream) @@ -573,9 +575,17 @@ public string GetDocumentationType(IType type) { result = string.Format(CultureInfo.InvariantCulture, "list of {0}", GetDocumentationType(listType.ElementType)); } - else if (type is EnumType) + else if (enumType != null) { - result = "str"; + if (enumType == ReturnType.Body) + { + if (enumType.ModelAsString) + result = "str"; + else + result = string.Format(CultureInfo.InvariantCulture, ":class:`{0} <{1}.models.{0}>`", enumType.Name, modelNamespace); + } + else + result = string.Format(CultureInfo.InvariantCulture, "str or :class:`{0} <{1}.models.{0}>`", enumType.Name, modelNamespace); } else if (type is DictionaryType) { @@ -583,7 +593,6 @@ public string GetDocumentationType(IType type) } else if (type is CompositeType) { - var modelNamespace = ServiceClient.Name.ToPythonCase().Replace("_", ""); if (!ServiceClient.Namespace.IsNullOrEmpty()) modelNamespace = ServiceClient.Namespace.ToPythonCase().Replace("_", ""); result = string.Format(CultureInfo.InvariantCulture, ":class:`{0} <{1}.models.{0}>`", type.Name, modelNamespace); diff --git a/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs index 2c43e7c092ca7..8ae4061b940b5 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/ModelTemplateModel.cs @@ -465,7 +465,7 @@ public string GetPropertyDocumentationType(IType type) } string result = "object"; - + var modelNamespace = ServiceClient.Name.ToPythonCase().Replace("_", ""); var listType = type as SequenceType; if (type is PrimaryType) { @@ -477,7 +477,7 @@ public string GetPropertyDocumentationType(IType type) } else if (type is EnumType) { - result = "str"; + result = string.Format(CultureInfo.InvariantCulture, "str or :class:`{0} <{1}.models.{0}>`", type.Name, modelNamespace); } else if (type is DictionaryType) { @@ -485,7 +485,6 @@ public string GetPropertyDocumentationType(IType type) } else if (type is CompositeType) { - var modelNamespace = ServiceClient.Name.ToPythonCase().Replace("_", ""); if (!ServiceClient.Namespace.IsNullOrEmpty()) modelNamespace = ServiceClient.Namespace.ToPythonCase().Replace("_", ""); result = string.Format(CultureInfo.InvariantCulture, ":class:`{0} <{1}.models.{0}>`", type.Name, modelNamespace); diff --git a/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs index 60629ea26ca28..24317c08c1faa 100644 --- a/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/Python/Python/TemplateModels/ServiceClientTemplateModel.cs @@ -105,6 +105,24 @@ public virtual string RequiredConstructorParameters } } + public virtual string ConfigConstructorParameters + { + get + { + var configParams = new List(); + foreach (var property in this.Properties) + { + configParams.Add(property.Name.ToPythonCase()); + } + var param = string.Join(", ", configParams); + if (!param.IsNullOrEmpty()) + { + param += ", "; + } + return param; + } + } + [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"), diff --git a/AutoRest/Generators/Python/Python/Templates/ServiceClientInitTemplate.cshtml b/AutoRest/Generators/Python/Python/Templates/ServiceClientInitTemplate.cshtml index fa51a54aafb30..d2bce3c67bd79 100644 --- a/AutoRest/Generators/Python/Python/Templates/ServiceClientInitTemplate.cshtml +++ b/AutoRest/Generators/Python/Python/Templates/ServiceClientInitTemplate.cshtml @@ -9,13 +9,10 @@ @Header("# ").TrimMultilineHeader() # -------------------------------------------------------------------------- @EmptyLine -from .@(Model.Name.ToPythonCase()) import @(Model.Name), @(Model.Name)Configuration +from .@(Model.Name.ToPythonCase()) import @(Model.Name) from .version import VERSION @EmptyLine -__all__ = [ - '@(Model.Name)', - '@(Model.Name)Configuration' -] +__all__ = ['@(Model.Name)'] @EmptyLine __version__ = VERSION @EmptyLine \ No newline at end of file diff --git a/AutoRest/Generators/Python/Python/Templates/ServiceClientTemplate.cshtml b/AutoRest/Generators/Python/Python/Templates/ServiceClientTemplate.cshtml index 9172b54791c76..5a93943f28a56 100644 --- a/AutoRest/Generators/Python/Python/Templates/ServiceClientTemplate.cshtml +++ b/AutoRest/Generators/Python/Python/Templates/ServiceClientTemplate.cshtml @@ -86,8 +86,8 @@ else class @(Model.Name)(object): """@Model.ServiceDocument @EmptyLine - :param config: Configuration for client. - :type config: @(Model.Name)Configuration + :ivar config: Configuration for client. + :vartype config: @(Model.Name)Configuration @if (Model.MethodGroupModels.Any()) { @EmptyLine @@ -97,11 +97,25 @@ class @(Model.Name)(object): @: :vartype @(methodGroup.MethodGroupName.ToPythonCase()): .operations.@(methodGroup.MethodGroupType) } } +@EmptyLine +@foreach (var property in Model.Properties) +{ +@: @ParameterWrapComment(string.Empty, ServiceClientTemplateModel.GetPropertyDocumentationString(property)) +@: @ParameterWrapComment(string.Empty, ":type " + property.Name + ": " + Model.GetPropertyDocumentationType(property.Type)) +} + +@if (!Model.IsCustomBaseUri) +{ +@: :param str base_url: Service URL +} + :param str filepath: Existing config """ @EmptyLine - def __init__(self, config): + def __init__( + self, @(Model.RequiredConstructorParameters)@(Model.IsCustomBaseUri ? "" : "base_url=None, ")filepath=None): @EmptyLine - self._client = ServiceClient(@(Model.Properties.Any(p => p.Type.IsPrimaryType(KnownPrimaryType.Credentials)) ? "config.credentials" : PythonConstants.None), config) + self.config = @(Model.Name)Configuration(@(Model.ConfigConstructorParameters)@(Model.IsCustomBaseUri ? "" : "base_url, ")filepath) + self._client = ServiceClient(@(Model.Properties.Any(p => p.Type.IsPrimaryType(KnownPrimaryType.Credentials)) ? "self.config.credentials" : PythonConstants.None), self.config) @EmptyLine @if (Model.ModelTemplateModels.Any()) { @@ -111,10 +125,9 @@ else { @:client_models = {} } - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) @EmptyLine - self.config = config @foreach (var methodGroup in Model.MethodGroupModels) { @:self.@(methodGroup.MethodGroupName.ToPythonCase()) = @(methodGroup.MethodGroupType)( diff --git a/AutoRest/Generators/Ruby/Ruby/ClientModelExtensions.cs b/AutoRest/Generators/Ruby/Ruby/ClientModelExtensions.cs index 853c37f8ea7e7..d5bd90e7ea0dd 100644 --- a/AutoRest/Generators/Ruby/Ruby/ClientModelExtensions.cs +++ b/AutoRest/Generators/Ruby/Ruby/ClientModelExtensions.cs @@ -180,7 +180,7 @@ public static string GetFormattedReferenceValue(this Parameter parameter) SequenceType sequence = parameter.Type as SequenceType; if (sequence == null) { - return parameter.Type.ToString(parameter.Name); + return parameter.Name; } PrimaryType primaryType = sequence.ElementType as PrimaryType; diff --git a/AutoRest/NugetPackageTest/packages.config b/AutoRest/NugetPackageTest/packages.config index 356cf06d88364..6cc4944dba66b 100644 --- a/AutoRest/NugetPackageTest/packages.config +++ b/AutoRest/NugetPackageTest/packages.config @@ -1,7 +1,7 @@ - + diff --git a/AutoRest/TestServer/server/app.js b/AutoRest/TestServer/server/app.js index 9453e73965c22..a462baa91787d 100644 --- a/AutoRest/TestServer/server/app.js +++ b/AutoRest/TestServer/server/app.js @@ -419,7 +419,7 @@ 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 + //Once all the languages implement this test, the scenario counter should be reset to zero. It is currently implemented in C#, Python and node.js "CustomBaseUriMoreOptions": 1, 'getModelFlattenArray': 0, 'putModelFlattenArray': 0, @@ -430,7 +430,7 @@ var coverage = { 'putModelFlattenCustomBase': 0, 'postModelFlattenCustomParameter': 0, 'putModelFlattenCustomGroupedParameter': 0, - /* TODO: only C# and node.js support the base64url format currently. Exclude these tests from code coverage until it is implemented in other languages */ + /* TODO: only C#, Python and node.js support the base64url format currently. Exclude these tests from code coverage until it is implemented in other languages */ "getStringBase64Encoded": 1, "getStringBase64UrlEncoded": 1, "putStringBase64UrlEncoded": 1, @@ -439,7 +439,7 @@ var coverage = { "getDictionaryBase64Url": 1, "UrlPathsStringBase64Url": 1, "UrlPathsArrayCSVInPath": 1, - /* TODO: only C# supports the unixtime format currently. Exclude these tests from code coverage until it is implemented in other languages */ + /* TODO: only C# and Python support the unixtime format currently. Exclude these tests from code coverage until it is implemented in other languages */ "getUnixTime": 1, "getInvalidUnixTime": 1, "getNullUnixTime": 1, diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure.Tests/LongRunningOperationsTest.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure.Tests/LongRunningOperationsTest.cs index 1d0bb2069f1bf..014446a6b9eb4 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure.Tests/LongRunningOperationsTest.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure.Tests/LongRunningOperationsTest.cs @@ -774,6 +774,12 @@ private IEnumerable MockPutOperaionWithoutProvisioningState }; yield return response1; + + var response2 = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent("{ \"properties\": { }, \"id\": \"100\", \"name\": \"foo\" }") + }; + yield return response2; } private IEnumerable MockPutOperaionWitNonResource() diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs index 422f074bd3028..180b9e8adddde 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/AzureClientExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Rest.Azure public static class AzureClientExtensions { /// - /// Gets operation result for PUT and PATCH operations. + /// Gets operation result for long running operations. /// /// Type of the resource body /// IAzureClient @@ -27,11 +27,11 @@ public static class AzureClientExtensions /// Headers that will be added to request /// Cancellation token /// Response with created resource - public static async Task> GetPutOrPatchOperationResultAsync( + public static async Task> GetLongRunningOperationResultAsync( this IAzureClient client, AzureOperationResponse response, Dictionary> customHeaders, - CancellationToken cancellationToken) where TBody : class + CancellationToken cancellationToken) where TBody : class { if (response == null) { @@ -44,7 +44,7 @@ public static async Task> GetPutOrPatchOperationRe RequestId = response.RequestId, Response = response.Response }; - var longRunningResponse = await GetPutOrPatchOperationResultAsync(client, headerlessResponse, customHeaders, cancellationToken); + var longRunningResponse = await GetLongRunningOperationResultAsync(client, headerlessResponse, customHeaders, cancellationToken); return new AzureOperationResponse { Body = longRunningResponse.Body, @@ -55,7 +55,7 @@ public static async Task> GetPutOrPatchOperationRe } /// - /// Gets operation result for PUT and PATCH operations. + /// Gets operation result for long running operations. /// /// Type of the resource body /// Type of the resource header @@ -64,7 +64,7 @@ public static async Task> GetPutOrPatchOperationRe /// Headers that will be added to request /// Cancellation token /// Response with created resource - public static async Task> GetPutOrPatchOperationResultAsync( + public static async Task> GetLongRunningOperationResultAsync( this IAzureClient client, AzureOperationResponse response, Dictionary> customHeaders, @@ -74,11 +74,29 @@ public static async Task> GetPutOrPatchOp { throw new ValidationException(ValidationRules.CannotBeNull, "response"); } - if (response.Response.StatusCode != HttpStatusCode.OK && - response.Response.StatusCode != HttpStatusCode.Accepted && - response.Response.StatusCode != HttpStatusCode.Created) + + if (response.Response == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "response.Response"); + } + + if (response.Request == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "response.Request"); + } + + if (response.Request.Method == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "response.Request.Method"); + } + + var initialRequestMethod = response.Request.Method; + if (CheckResponseStatusCodeFailed(response)) { - throw new CloudException(string.Format(Resources.UnexpectedPollingStatus, response.Response.StatusCode)); + throw new CloudException(string.Format( + Resources.UnexpectedPollingStatus, + response.Response.StatusCode, + initialRequestMethod)); } var pollingState = new PollingState(response, client.LongRunningOperationRetryTimeout); @@ -92,24 +110,31 @@ public static async Task> GetPutOrPatchOp if (!string.IsNullOrEmpty(pollingState.AzureAsyncOperationHeaderLink)) { - await UpdateStateFromAzureAsyncOperationHeader(client, pollingState, customHeaders, false, cancellationToken); + await UpdateStateFromAzureAsyncOperationHeader(client, pollingState, customHeaders, cancellationToken); } else if (!string.IsNullOrEmpty(pollingState.LocationHeaderLink)) { - await UpdateStateFromLocationHeaderOnPut(client, pollingState, customHeaders, cancellationToken); + await UpdateStateFromLocationHeader(client, pollingState, customHeaders, cancellationToken, initialRequestMethod); } - else + else if (initialRequestMethod == HttpMethod.Put) { - await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, + await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, customHeaders, cancellationToken); } + else + { + throw new CloudException("Location header is missing from long running operation."); + } } - if (AzureAsyncOperation.SuccessStatus.Equals(pollingState.Status, StringComparison.OrdinalIgnoreCase) && - pollingState.Resource == null) + if (AzureAsyncOperation.SuccessStatus.Equals(pollingState.Status, StringComparison.OrdinalIgnoreCase)) { - await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, - customHeaders, cancellationToken); + if ((!string.IsNullOrEmpty(pollingState.AzureAsyncOperationHeaderLink) || pollingState.Resource == null) && + (initialRequestMethod == HttpMethod.Put || initialRequestMethod == new HttpMethod("PATCH"))) + { + await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, customHeaders, + cancellationToken); + } } // Check if operation failed @@ -123,14 +148,14 @@ await UpdateStateFromGetResourceOperation(client, pollingState, getOperationUrl, } /// - /// Gets operation result for PUT and PATCH operations. + /// Gets operation result for long running operations. /// /// IAzureClient /// Response from the begin operation /// Headers that will be added to request /// Cancellation token /// Operation response - public static async Task GetPutOrPatchOperationResultAsync( + public static async Task GetLongRunningOperationResultAsync( this IAzureClient client, AzureOperationResponse response, Dictionary> customHeaders, @@ -143,7 +168,7 @@ public static async Task GetPutOrPatchOperationResultAsy RequestId = response.RequestId }; - var azureOperationResponse = await client.GetPutOrPatchOperationResultAsync( + var azureOperationResponse = await client.GetLongRunningOperationResultAsync( newResponse, customHeaders, cancellationToken); return new AzureOperationResponse @@ -155,35 +180,35 @@ public static async Task GetPutOrPatchOperationResultAsy } /// - /// Gets operation result for DELETE and POST operations. + /// Gets operation result for long running operations. /// - /// Type of the resource body + /// Type of the resource headers /// IAzureClient /// Response from the begin operation /// Headers that will be added to request /// Cancellation token /// Operation response - public static async Task> GetPostOrDeleteOperationResultAsync( + public static async Task> GetLongRunningOperationResultAsync( this IAzureClient client, - AzureOperationResponse response, + AzureOperationHeaderResponse response, Dictionary> customHeaders, - CancellationToken cancellationToken) where TBody : class + CancellationToken cancellationToken) where THeader : class { if (response == null) { throw new ArgumentNullException("response"); } - var headerlessResponse = new AzureOperationResponse + var headerlessResponse = new AzureOperationResponse { - Body = response.Body, + Headers = response.Headers, Request = response.Request, RequestId = response.RequestId, Response = response.Response }; - var longRunningResponse = await GetPostOrDeleteOperationResultAsync(client, headerlessResponse, customHeaders, cancellationToken); - return new AzureOperationResponse + var longRunningResponse = await GetLongRunningOperationResultAsync(client, headerlessResponse, customHeaders, cancellationToken); + return new AzureOperationHeaderResponse { - Body = longRunningResponse.Body, + Headers = longRunningResponse.Headers, Request = longRunningResponse.Request, RequestId = longRunningResponse.RequestId, Response = longRunningResponse.Response @@ -191,7 +216,81 @@ public static async Task> GetPostOrDeleteOperation } /// - /// Gets operation result for DELETE and POST operations. + /// Gets operation result for PUT and PATCH operations. (Deprecated, please use GetLongRunningOperationResultAsync) + /// + /// Type of the resource body + /// IAzureClient + /// Response from the begin operation + /// Headers that will be added to request + /// Cancellation token + /// Response with created resource + public static async Task> GetPutOrPatchOperationResultAsync( + this IAzureClient client, + AzureOperationResponse response, + Dictionary> customHeaders, + CancellationToken cancellationToken) where TBody : class + { + return await client.GetLongRunningOperationResultAsync( + response, customHeaders, cancellationToken); + } + + /// + /// Gets operation result for PUT and PATCH operations. (Deprecated, please use GetLongRunningOperationResultAsync) + /// + /// Type of the resource body + /// Type of the resource header + /// IAzureClient + /// Response from the begin operation + /// Headers that will be added to request + /// Cancellation token + /// Response with created resource + public static async Task> GetPutOrPatchOperationResultAsync( + this IAzureClient client, + AzureOperationResponse response, + Dictionary> customHeaders, + CancellationToken cancellationToken) where TBody : class where THeader : class + { + return await GetLongRunningOperationResultAsync(client, response, customHeaders, cancellationToken); + } + + /// + /// Gets operation result for PUT and PATCH operations. (Deprecated, please use GetLongRunningOperationResultAsync) + /// + /// 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) + { + return await client.GetLongRunningOperationResultAsync( + response, customHeaders, cancellationToken); + } + + /// + /// Gets operation result for DELETE and POST operations. (Deprecated, please use GetLongRunningOperationResultAsync) + /// + /// Type of the resource body + /// IAzureClient + /// Response from the begin operation + /// Headers that will be added to request + /// Cancellation token + /// Operation response + public static async Task> GetPostOrDeleteOperationResultAsync( + this IAzureClient client, + AzureOperationResponse response, + Dictionary> customHeaders, + CancellationToken cancellationToken) where TBody : class + { + return await GetLongRunningOperationResultAsync(client, response, customHeaders, cancellationToken); + } + + /// + /// Gets operation result for DELETE and POST operations. (Deprecated, please use GetLongRunningOperationResultAsync) /// /// Type of the resource headers /// IAzureClient @@ -205,29 +304,11 @@ public static async Task> GetPostOrDeleteO Dictionary> customHeaders, CancellationToken cancellationToken) where THeader : class { - if (response == null) - { - throw new ArgumentNullException("response"); - } - var headerlessResponse = new AzureOperationResponse - { - Headers = response.Headers, - Request = response.Request, - RequestId = response.RequestId, - Response = response.Response - }; - var longRunningResponse = await GetPostOrDeleteOperationResultAsync(client, headerlessResponse, customHeaders, cancellationToken); - return new AzureOperationHeaderResponse - { - Headers = longRunningResponse.Headers, - Request = longRunningResponse.Request, - RequestId = longRunningResponse.RequestId, - Response = longRunningResponse.Response - }; + return await GetLongRunningOperationResultAsync(client, response, customHeaders, cancellationToken); } /// - /// Gets operation result for DELETE and POST operations. + /// Gets operation result for DELETE and POST operations. (Deprecated, please use GetLongRunningOperationResultAsync) /// /// Type of the resource body /// Type of the resource header @@ -242,57 +323,11 @@ public static async Task> GetPostOrDelete Dictionary> customHeaders, CancellationToken cancellationToken) where TBody : class where THeader : class { - if (response == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "response"); - } - - if (response.Response == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "response.Response"); - } - - if (response.Response.StatusCode != HttpStatusCode.OK && - response.Response.StatusCode != HttpStatusCode.Accepted && - response.Response.StatusCode != HttpStatusCode.NoContent) - { - throw new CloudException(string.Format(Resources.UnexpectedPollingStatus, response.Response.StatusCode)); - } - - var pollingState = new PollingState(response, client.LongRunningOperationRetryTimeout); - - // Check provisioning state - while (!AzureAsyncOperation.TerminalStatuses.Any(s => s.Equals(pollingState.Status, - StringComparison.OrdinalIgnoreCase))) - { - await Task.Delay(pollingState.DelayInMilliseconds, cancellationToken).ConfigureAwait(false); - - if (!string.IsNullOrEmpty(pollingState.AzureAsyncOperationHeaderLink)) - { - await UpdateStateFromAzureAsyncOperationHeader(client, pollingState, customHeaders,true, cancellationToken); - } - else if (!string.IsNullOrEmpty(pollingState.LocationHeaderLink)) - { - await UpdateStateFromLocationHeaderOnPostOrDelete(client, pollingState, customHeaders, cancellationToken); - } - else - { - throw new CloudException(Resources.NoHeader); - } - } - - // Check if operation failed - if (AzureAsyncOperation.FailedStatuses.Any( - s => s.Equals(pollingState.Status, StringComparison.OrdinalIgnoreCase))) - { - throw pollingState.CloudException; - } - - return pollingState.AzureOperationResponse; + return await GetLongRunningOperationResultAsync(client, response, customHeaders, cancellationToken); } /// - /// Gets operation result for DELETE and POST operations. + /// Gets operation result for DELETE and POST operations. (Deprecated, please use GetLongRunningOperationResultAsync) /// /// IAzureClient /// Response from the begin operation @@ -305,22 +340,21 @@ public static async Task GetPostOrDeleteOperationResultA Dictionary> customHeaders, CancellationToken cancellationToken) { - var newResponse = new AzureOperationResponse - { - Request = response.Request, - Response = response.Response, - RequestId = response.RequestId - }; - - var azureOperationResponse = await client.GetPostOrDeleteOperationResultAsync( - newResponse, customHeaders, cancellationToken); + return await client.GetLongRunningOperationResultAsync(response, customHeaders, cancellationToken); + } - return new AzureOperationResponse + private static bool CheckResponseStatusCodeFailed( + AzureOperationResponse initialResponse) + { + var statusCode = initialResponse.Response.StatusCode; + var method = initialResponse.Request.Method; + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Accepted || + (statusCode == HttpStatusCode.Created && method == HttpMethod.Put) || + (statusCode == HttpStatusCode.NoContent && (method == HttpMethod.Delete || method == HttpMethod.Post))) { - Request = azureOperationResponse.Request, - Response = azureOperationResponse.Response, - RequestId = azureOperationResponse.RequestId - }; + return false; + } + return true; } /// @@ -375,7 +409,7 @@ private static async Task UpdateStateFromGetResourceOperation( } /// - /// Updates PollingState from Location header on Put operations. + /// Updates PollingState from Location header. /// /// Type of the resource body. /// Type of the resource header. @@ -383,12 +417,14 @@ private static async Task UpdateStateFromGetResourceOperation( /// Current polling state. /// Headers that will be added to request /// Cancellation token + /// Http method of the initial long running operation request /// Task. - private static async Task UpdateStateFromLocationHeaderOnPut( + private static async Task UpdateStateFromLocationHeader( IAzureClient client, PollingState pollingState, Dictionary> customHeaders, - CancellationToken cancellationToken) where TBody : class where THeader : class + CancellationToken cancellationToken, + HttpMethod method) where TBody : class where THeader : class { AzureOperationResponse responseWithResource = await client.GetRawAsync( pollingState.LocationHeaderLink, @@ -404,73 +440,24 @@ private static async Task UpdateStateFromLocationHeaderOnPut( pollingState.Status = AzureAsyncOperation.InProgressStatus; } else if (statusCode == HttpStatusCode.OK || - statusCode == HttpStatusCode.Created) + (statusCode == HttpStatusCode.Created && method == HttpMethod.Put) || + (statusCode == HttpStatusCode.NoContent && (method == HttpMethod.Delete || method == HttpMethod.Post))) { - if (responseWithResource.Body == null) - { - throw new CloudException(Resources.NoBody); - } - - // In 202 pattern on PUT ProvisioningState may not be present in - // the response. In that case the assumption is the status is Succeeded. - var resource = responseWithResource.Body; - if (resource["properties"] != null && resource["properties"]["provisioningState"] != null) - { - pollingState.Status = (string)resource["properties"]["provisioningState"]; - } - else - { - pollingState.Status = AzureAsyncOperation.SuccessStatus; - } + pollingState.Status = AzureAsyncOperation.SuccessStatus; pollingState.Error = new CloudError() { Code = pollingState.Status, Message = string.Format(Resources.LongRunningOperationFailed, pollingState.Status) }; - pollingState.Resource = responseWithResource.Body.ToObject(JsonSerializer + pollingState.Resource = responseWithResource.Body == null ? null : responseWithResource.Body.ToObject(JsonSerializer .Create(client.DeserializationSettings)); pollingState.ResourceHeaders = responseWithResource.Headers.ToObject(JsonSerializer .Create(client.DeserializationSettings)); } - } - - /// - /// Updates PollingState from Location header on Post or Delete operations. - /// - /// Type of the resource body. - /// Type of the resource header. - /// IAzureClient - /// Current polling state. - /// Headers that will be added to request - /// Cancellation token - /// Task. - private static async Task UpdateStateFromLocationHeaderOnPostOrDelete( - IAzureClient client, - PollingState pollingState, - Dictionary> customHeaders, - CancellationToken cancellationToken) where TBody : class where THeader : class - { - AzureOperationResponse responseWithResource = await client.GetAsync( - pollingState.LocationHeaderLink, - customHeaders, - cancellationToken).ConfigureAwait(false); - - pollingState.Response = responseWithResource.Response; - pollingState.Request = responseWithResource.Request; - pollingState.ResourceHeaders = responseWithResource.Headers; - - var statusCode = responseWithResource.Response.StatusCode; - if (statusCode == HttpStatusCode.Accepted) - { - pollingState.Status = AzureAsyncOperation.InProgressStatus; - } - else if (statusCode == HttpStatusCode.OK || - statusCode == HttpStatusCode.Created || - statusCode == HttpStatusCode.NoContent) + else { - pollingState.Status = AzureAsyncOperation.SuccessStatus; - pollingState.Resource = responseWithResource.Body; + throw new CloudException("The response from long running operation does not have a valid status code."); } } @@ -482,14 +469,12 @@ private static async Task UpdateStateFromLocationHeaderOnPostOrDeleteIAzureClient /// Current polling state. /// Headers that will be added to request - /// Headers that will be added to request /// Cancellation token /// Task. private static async Task UpdateStateFromAzureAsyncOperationHeader( IAzureClient client, PollingState pollingState, - Dictionary> customHeaders, - bool postOrDelete, + Dictionary> customHeaders, CancellationToken cancellationToken) where TBody : class where THeader : class { AzureOperationResponse asyncOperationResponse = @@ -508,21 +493,18 @@ await client.GetAsync( pollingState.Response = asyncOperationResponse.Response; pollingState.Request = asyncOperationResponse.Request; pollingState.Resource = null; - if (postOrDelete) - { - //Try to de-serialize to the response model. (Not required for "PutOrPatch" - //which has the fallback of invoking generic "resource get".) - string responseContent = await pollingState.Response.Content.ReadAsStringAsync(); - var responseHeaders = pollingState.Response.Headers.ToJson(); - try - { - pollingState.Resource = JObject.Parse(responseContent) - .ToObject(JsonSerializer.Create(client.DeserializationSettings)); - pollingState.ResourceHeaders = - responseHeaders.ToObject(JsonSerializer.Create(client.DeserializationSettings)); - } - catch { }; + //Try to de-serialize to the response model. (Not required for "PutOrPatch" + //which has the fallback of invoking generic "resource get".) + string responseContent = await pollingState.Response.Content.ReadAsStringAsync(); + var responseHeaders = pollingState.Response.Headers.ToJson(); + try + { + pollingState.Resource = JObject.Parse(responseContent) + .ToObject(JsonSerializer.Create(client.DeserializationSettings)); + pollingState.ResourceHeaders = + responseHeaders.ToObject(JsonSerializer.Create(client.DeserializationSettings)); } + catch { }; } /// diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/PollingState.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/PollingState.cs index 26681f0f7e594..17c38105b0b37 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/PollingState.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/PollingState.cs @@ -46,29 +46,39 @@ public PollingState(HttpOperationResponse response, int? retryTi } } - if (resource != null && resource["properties"] != null && - resource["properties"]["provisioningState"] != null) + switch (Response.StatusCode) { - Status = (string)resource["properties"]["provisioningState"]; - } - else - { - switch (Response.StatusCode) - { - case HttpStatusCode.Accepted: - Status = AzureAsyncOperation.InProgressStatus; - break; - - case HttpStatusCode.NoContent: - case HttpStatusCode.Created: - case HttpStatusCode.OK: + case HttpStatusCode.Accepted: + Status = AzureAsyncOperation.InProgressStatus; + break; + case HttpStatusCode.OK: + if (resource != null && resource["properties"] != null && + resource["properties"]["provisioningState"] != null) + { + Status = (string)resource["properties"]["provisioningState"]; + } + else + { Status = AzureAsyncOperation.SuccessStatus; - break; - - default: - Status = AzureAsyncOperation.FailedStatus; - break; - } + } + break; + case HttpStatusCode.Created: + if (resource != null && resource["properties"] != null && + resource["properties"]["provisioningState"] != null) + { + Status = (string) resource["properties"]["provisioningState"]; + } + else + { + Status = AzureAsyncOperation.InProgressStatus; + } + break; + case HttpStatusCode.NoContent: + Status = AzureAsyncOperation.SuccessStatus; + break; + default: + Status = AzureAsyncOperation.FailedStatus; + break; } } diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.Designer.cs b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.Designer.cs index fb148df5bdf7c..04e84d7a82b8e 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.Designer.cs +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.Designer.cs @@ -304,7 +304,7 @@ internal static string TaskMustBeScheduled { } /// - /// Looks up a localized string similar to Unexpected polling status code from long running operation '{0}'.. + /// Looks up a localized string similar to Unexpected polling status code from long running operation '{0}' for method '{1}'.. /// internal static string UnexpectedPollingStatus { get { diff --git a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.resx b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.resx index 496a6c2483ade..8fb340da09bbb 100644 --- a/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.resx +++ b/ClientRuntimes/CSharp/Microsoft.Rest.ClientRuntime.Azure/Properties/Resources.resx @@ -200,6 +200,6 @@ Parameter name: {0} The specified argument '{0}' must return a scheduled task (also known as "hot" task) when invoked. - Unexpected polling status code from long running operation '{0}'. + Unexpected polling status code from long running operation '{0}' for method '{1}'. \ No newline at end of file diff --git a/ClientRuntimes/Java/azure-android-client-authentication/build.gradle b/ClientRuntimes/Java/azure-android-client-authentication/build.gradle index 0884db281a5a1..82a0cc5107a08 100644 --- a/ClientRuntimes/Java/azure-android-client-authentication/build.gradle +++ b/ClientRuntimes/Java/azure-android-client-authentication/build.gradle @@ -42,7 +42,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.microsoft.aad:adal:1.1.11' - compile 'com.microsoft.rest:client-runtime:1.0.0-beta1' + compile 'com.microsoft.rest:client-runtime:1.0.0-SNAPSHOT' testCompile 'junit:junit:4.12' testCompile 'junit:junit-dep:4.11' deployerJars "org.apache.maven.wagon:wagon-ftp:2.10" @@ -116,4 +116,4 @@ artifacts { archives sourcesJar archives javadocJar archives file: file("${projectDir}/.gitrevision") -} \ No newline at end of file +} diff --git a/ClientRuntimes/Java/azure-client-authentication/build.gradle b/ClientRuntimes/Java/azure-client-authentication/build.gradle index a04020e1fd378..eaac35660cce9 100644 --- a/ClientRuntimes/Java/azure-client-authentication/build.gradle +++ b/ClientRuntimes/Java/azure-client-authentication/build.gradle @@ -20,7 +20,7 @@ checkstyle { dependencies { compile 'com.microsoft.azure:adal4j:1.1.2' - compile 'com.microsoft.rest:client-runtime:1.0.0-beta1' + compile 'com.microsoft.rest:client-runtime:1.0.0-SNAPSHOT' testCompile 'junit:junit:4.12' testCompile 'junit:junit-dep:4.11' deployerJars "org.apache.maven.wagon:wagon-ftp:2.10" @@ -105,4 +105,4 @@ test { reports.html.destination = file("${projectDir}/../../../TestResults/JavaAzureRuntime") } -tasks.compileJava.dependsOn 'clean' \ No newline at end of file +tasks.compileJava.dependsOn 'clean' diff --git a/ClientRuntimes/Java/azure-client-runtime/build.gradle b/ClientRuntimes/Java/azure-client-runtime/build.gradle index 3d90bc184cff5..dcdaddcea285b 100644 --- a/ClientRuntimes/Java/azure-client-runtime/build.gradle +++ b/ClientRuntimes/Java/azure-client-runtime/build.gradle @@ -20,7 +20,7 @@ checkstyle { } dependencies { - compile 'com.microsoft.rest:client-runtime:1.0.0-beta1' + compile 'com.microsoft.rest:client-runtime:1.0.0-SNAPSHOT' testCompile 'junit:junit:4.12' testCompile 'junit:junit-dep:4.11' deployerJars "org.apache.maven.wagon:wagon-ftp:2.10" diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/README.md b/ClientRuntimes/NodeJS/ms-rest-azure/README.md index fa4dfef78d951..676f99f91a4ab 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/README.md +++ b/ClientRuntimes/NodeJS/ms-rest-azure/README.md @@ -2,7 +2,7 @@ Infrastructure for error handling, tracing, and http client pipeline configuration. Required by nodeJS Azure client libraries, generated using AutoRest. -- **Node.js version: 0.10.0 or higher** +- **Node.js version: 4.x.x or higher** ## How to Install @@ -17,15 +17,52 @@ var msrestAzure = require('ms-rest-azure'); ``` ## Authentication +#### Interactive Login is the simplest and the best way to authenticate. +It provides a url and code that needs to be copied and pasted in a browser and authenticated over there. If successful, +the user will get a DeviceTokenCredentials object. ```javascript - //user authentication - var credentials = new msRestAzure.UserTokenCredentials('your-client-id', 'your-domain', 'your-username', 'your-password', 'your-redirect-uri'); - //service principal authentication - var credentials = new msRestAzure.ApplicationTokenCredentials('your-client-id', 'your-domain', 'your-secret'); + var someAzureServiceClient = require('azure-arm-someService'); + msRestAzure.interactiveLogin(function(err, credentials) { + if (err) return console.log(err); + var client = new someAzureServiceClient(credentials, 'your-subscriptionId'); + client.someOperationGroup.method(param1, param2, function(err, result) { + if (err) return console.log(err); + return console.log(result); + }); + }); ``` + +#### Login with username and password +This mechanism will only work for organizational ids and ids that are not 2FA enabled. +Otherwise it is better to use the above mechanism (interactive login). +```javascript + var someAzureServiceClient = require('azure-arm-someService'); + msRestAzure.loginWithUsernamePassword(username, password, function(err, credentials) { + if (err) return console.log(err); + var client = new someAzureServiceClient(credentials, 'your-subscriptionId'); + client.someOperationGroup.method(param1, param2, function(err, result) { + if (err) return console.log(err); + return console.log(result); + }); + }); +``` + ### Non-Interactive Authentication -If you need to create an automation account for non interactive or scripting scenarios then please take a look at the documentation over [here](https://github.com/Azure/azure-sdk-for-node/blob/autorest/Documentation/Authentication.md). +If you need to create an automation account for non interactive or scripting scenarios then please take a look at the documentation over [here](https://github.com/Azure/azure-sdk-for-node/blob/master/Documentation/Authentication.md). Once you have created a service principal you can authenticate using the following code snippet. + +#### Login with service principal name and secret +```javascript + var someAzureServiceClient = require('azure-arm-someService'); + msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain, function(err, credentials) { + if (err) return console.log(err); + var client = new someAzureServiceClient(credentials, 'your-subscriptionId'); + client.someOperationGroup.method(param1, param2, function(err, result) { + if (err) retutrn console.log(err); + return console.log(result); + }); + }); +``` ## Related Projects -- [AutoRest](https://github.com/Azure/AutoRest) \ No newline at end of file +- [AutoRest](https://github.com/Azure/AutoRest) diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js index 1341dc4f10365..c2badda1e264e 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/constants.js @@ -14,7 +14,13 @@ var Constants = { Succeeded: 'Succeeded', Failed: 'Failed', Canceled: 'Canceled' - } + }, + + DEFAULT_ADAL_CLIENT_ID: '04b07795-8ddb-461a-bbee-02f9e1bf7b46', + + AAD_COMMON_TENANT: 'common', + + DEFAULT_LANGUAGE: 'en-us' }; exports = module.exports = Constants; diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js index e096edbff2049..6c1df592b28ae 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/applicationTokenCredentials.js @@ -19,7 +19,7 @@ var AzureEnvironment = require('../azureEnvironment'); * @param {object} [options] Object representing optional parameters. * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. -* @param {object} [options.tokenCache] The token cache. Default value is null. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. */ function ApplicationTokenCredentials(clientId, domain, secret, options) { if (!Boolean(clientId) || typeof clientId.valueOf() !== 'string') { @@ -39,23 +39,60 @@ function ApplicationTokenCredentials(clientId, domain, secret, options) { } if (!options.environment) { - this.environment = AzureEnvironment.Azure; - } else { - this.environment = options.environment; + options.environment = AzureEnvironment.Azure; } if (!options.authorizationScheme) { - this.authorizationScheme = 'Bearer'; - } else { - this.authorizationScheme = options.authorizationScheme; + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; } - + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + this.environment = options.environment; + this.authorizationScheme = options.authorizationScheme; this.tokenCache = options.tokenCache; this.clientId = clientId; this.domain = domain; this.secret = secret; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); } +function _retrieveTokenFromCache (callback) { + //For service principal userId and clientId are the same thing. Since the token has _clientId property we shall + //retrieve token using it. + this.context.acquireToken(this.environment.activeDirectoryResourceId, null, this.clientId, function (err, result) { + if (err) return callback(err); + return callback(null, result); + }); +} + +/** + * Tries to get the token from cache initially. If that is unsuccessfull then it tries to get the token from ADAL. + * @param {function} callback The callback in the form (err, result) + * @return {function} callback + * {Error} [err] The error if any + * {object} [tokenResponse] The tokenResponse (tokenType and accessToken are the two important properties). + */ +ApplicationTokenCredentials.prototype.getToken = function (callback) { + var self = this; + _retrieveTokenFromCache.call(this, function (err, result) { + if (err) { + //Some error occured in retrieving the token from cache. May be the cache was empty or the access token expired. Let's try again. + self.context.acquireTokenWithClientCredentials(self.environment.activeDirectoryResourceId, self.clientId, self.secret, function (err, tokenResponse) { + if (err) { + return callback(new Error('Failed to acquire token for application with the provided secret. \n' + err)); + } + return callback(null, tokenResponse); + }); + } else { + return callback(null, result); + } + }); +}; + /** * Signs a request with the Authentication header. * @@ -64,18 +101,11 @@ function ApplicationTokenCredentials(clientId, domain, secret, options) { * @return {undefined} */ ApplicationTokenCredentials.prototype.signRequest = function (webResource, callback) { - var self = this; - var authorityUrl = self.environment.activeDirectoryEndpointUrl + self.domain; - var context = new adal.AuthenticationContext(authorityUrl, self.environment.validateAuthority, self.tokenCache); - - context.acquireTokenWithClientCredentials(self.environment.activeDirectoryResourceId, self.clientId, self.secret, function (err, result) { - if (err) { - return callback(new Error('Failed to acquire token for application. \n' + err)); - } - + this.getToken(function (err, result) { + if (err) return callback(err); webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = - util.format('%s %s', self.authorizationScheme, result.accessToken); - callback(null); + util.format('%s %s', result.tokenType, result.accessToken); + return callback(null); }); }; diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js new file mode 100644 index 0000000000000..48cb16802acb3 --- /dev/null +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/deviceTokenCredentials.js @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +var util = require('util'); +var msrest = require('ms-rest'); +var adal = require('adal-node'); +var Constants = msrest.Constants; + +var azureConstants = require('../constants'); +var AzureEnvironment = require('../azureEnvironment'); + +/** +* Creates a new DeviceTokenCredentials object that gets a new access token using userCodeInfo (contains user_code, device_code) +* for authenticating user on device. +* +* When this credential is used, the script will provide a url and code. The user needs to copy the url and the code, paste it +* in a browser and authenticate over there. If successful, the script will get the access token. +* +* @constructor +* @param {object} [options] Object representing optional parameters. +* @param {string} [options.username] The user name for account in the form: 'user@example.com'. +* @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. Default environment is "Azure" popularly known as "Public Azure Cloud". +* @param {string} [options.domain] The domain or tenant id containing this application. Default value is 'common' +* @param {string} [options.clientId] The active directory application client id. +* See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} +* for an example. +* @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. +*/ +function DeviceTokenCredentials(options) { + if (!options) { + options = {}; + } + + if (!options.username) { + options.username = 'user@example.com'; + } + + if (!options.environment) { + options.environment = AzureEnvironment.Azure; + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + + if (!options.authorizationScheme) { + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + this.username = options.username; + this.environment = options.environment; + this.domain = options.domain; + this.clientId = options.clientId; + this.authorizationScheme = options.authorizationScheme; + this.tokenCache = options.tokenCache; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); +} + +DeviceTokenCredentials.prototype.retrieveTokenFromCache = function (callback) { + var self = this; + self.context.acquireToken(self.environment.activeDirectoryResourceId, self.username, self.clientId, function (err, result) { + if (err) return callback(err); + return callback(null, result.tokenType, result.accessToken); + }); +}; + + +/** +* Signs a request with the Authentication header. +* +* @param {webResource} The WebResource to be signed. +* @param {function(error)} callback The callback function. +* @return {undefined} +*/ +DeviceTokenCredentials.prototype.signRequest = function (webResource, callback) { + return this.retrieveTokenFromCache(function(err, scheme, token) { + if (err) return callback(err); + webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = util.format('%s %s', scheme, token); + return callback(null); + }); +}; + +module.exports = DeviceTokenCredentials; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js index 7b4f02cf720bf..12908b0edbbff 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/credentials/userTokenCredentials.js @@ -18,13 +18,12 @@ var AzureEnvironment = require('../azureEnvironment'); * @param {string} domain The domain or tenant id containing this application. * @param {string} username The user name for the Organization Id account. * @param {string} password The password for the Organization Id account. -* @param {string} clientRedirectUri The Uri where the user will be redirected after authenticating with AD. * @param {object} [options] Object representing optional parameters. * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. -* @param {object} [options.tokenCache] The token cache. Default value is null. +* @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. */ -function UserTokenCredentials(clientId, domain, username, password, clientRedirectUri, options) { +function UserTokenCredentials(clientId, domain, username, password, options) { if (!Boolean(clientId) || typeof clientId.valueOf() !== 'string') { throw new Error('clientId must be a non empty string.'); } @@ -40,35 +39,66 @@ function UserTokenCredentials(clientId, domain, username, password, clientRedire if (!Boolean(password) || typeof password.valueOf() !== 'string') { throw new Error('password must be a non empty string.'); } - - if (!Boolean(clientRedirectUri) || typeof clientRedirectUri.valueOf() !== 'string') { - throw new Error('clientRedirectUri cannot be null.'); - } if (!options) { options = {}; } if (!options.environment) { - this.environment = AzureEnvironment.Azure; - } else { - this.environment = options.environment; + options.environment = AzureEnvironment.Azure; } if (!options.authorizationScheme) { - this.authorizationScheme = 'Bearer'; - } else { - this.authorizationScheme = options.authorizationScheme; + options.authorizationScheme = Constants.HeaderConstants.AUTHORIZATION_SCHEME; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); } + this.environment = options.environment; + this.authorizationScheme = options.authorizationScheme; this.tokenCache = options.tokenCache; this.clientId = clientId; this.domain = domain; this.username = username; this.password = password; - this.clientRedirectUri = clientRedirectUri; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); } +function _retrieveTokenFromCache(callback) { + this.context.acquireToken(this.environment.activeDirectoryResourceId, this.username, this.clientId, function (err, result) { + if (err) return callback(err); + return callback(null, result); + }); +} + +/** + * Tries to get the token from cache initially. If that is unsuccessfull then it tries to get the token from ADAL. + * @param {function} callback The callback in the form (err, result) + * @return {function} callback + * {Error} [err] The error if any + * {object} [tokenResponse] The tokenResponse (tokenType and accessToken are the two important properties). + */ +UserTokenCredentials.prototype.getToken = function (callback) { + var self = this; + _retrieveTokenFromCache.call(this, function (err, result) { + if (err) { + //Some error occured in retrieving the token from cache. May be the cache was empty. Let's try again. + self.context.acquireTokenWithUsernamePassword(self.environment.activeDirectoryResourceId, self.username, + self.password, self.clientId, function (err, tokenResponse) { + if (err) { + return callback(new Error('Failed to acquire token for the user. \n' + err)); + } + return callback(null, tokenResponse); + }); + } else { + return callback(null, result); + } + }); +}; + /** * Signs a request with the Authentication header. * @@ -77,18 +107,11 @@ function UserTokenCredentials(clientId, domain, username, password, clientRedire * @return {undefined} */ UserTokenCredentials.prototype.signRequest = function (webResource, callback) { - var self = this; - var authorityUrl = self.environment.activeDirectoryEndpointUrl + self.domain; - var context = new adal.AuthenticationContext(authorityUrl, self.environment.validateAuthority, self.tokenCache); - - context.acquireTokenWithUsernamePassword(self.environment.activeDirectoryResourceId, self.username, self.password, self.clientId, function (err, result) { - if (err) { - return callback(new Error('Failed to acquire token. \n' + err)); - } - + this.getToken(function (err, result) { + if (err) return callback(err); webResource.headers[Constants.HeaderConstants.AUTHORIZATION] = - util.format('%s %s', self.authorizationScheme, result.accessToken); - callback(null); + util.format('%s %s', result.tokenType, result.accessToken); + return callback(null); }); }; diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/index.d.ts b/ClientRuntimes/NodeJS/ms-rest-azure/lib/index.d.ts index ef4378cff4e40..4d113e8c9ed54 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/index.d.ts +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/index.d.ts @@ -150,13 +150,40 @@ export interface AzureTokenCredentialsOptions { */ authorizationScheme?: string; - // TODO: What type should this really have? How is it used? /** - * The token cache. Default value is null. + * The token cache. Default value is MemoryCache from adal. */ tokenCache?: any; } +export interface LoginWithUsernamePasswordOptions extends AzureTokenCredentialsOptions { + /** + * The domain or tenant id containing this application. Default value is 'common'. + */ + domain?: string; + + /** + * The active directory application client id. + * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} + * for an example. + */ + clientId?: string +} + +export interface DeviceTokenCredentialsOptions extends LoginWithUsernamePasswordOptions { + /** + * The user name for account in the form: 'user@example.com'. Default value is 'user@example.com'. + */ + username?: string; +} + +export interface InteractiveLoginOptions extends DeviceTokenCredentialsOptions { + /** + * The language code specifying how the message should be localized to. Default value 'en-us'. + */ + language?: string; +} + export class ApplicationTokenCredentials extends msRest.ServiceClientCredentials { /** * Creates a new ApplicationTokenCredentials object. @@ -179,12 +206,79 @@ export class UserTokenCredentials extends msRest.ServiceClientCredentials { * @param {string} domain The domain or tenant id containing this application. * @param {string} username The user name for the Organization Id account. * @param {string} password The password for the Organization Id account. - * @param {string} clientRedirectUri The Uri where the user will be redirected after authenticating with AD. * @param {AzureTokenCredentialsOptions} options Object representing optional parameters. */ - constructor(clientId: string, domain: string, username: string, password: string, clientRedirectUri: string, options?: AzureTokenCredentialsOptions); + constructor(clientId: string, domain: string, username: string, password: string, options?: AzureTokenCredentialsOptions); +} + +export class DeviceTokenCredentials extends msRest.ServiceClientCredentials { + /** + * Creates a new DeviceTokenCredentials object. + * @param {DeviceTokenCredentialsOptions} options Object representing optional parameters. + */ + constructor(options?: DeviceTokenCredentialsOptions); } // TODO: WHAT SHOULD WE EXPOSE HERE? export class BaseResource { } + +/** + * Provides a url and code that needs to be copy and pasted in a browser and authenticated over there. If successful, the user will get a + * DeviceTokenCredentials object + * + * @param {InteractiveLoginOptions} [options] The parameter options. + * + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {DeviceTokenCredentials} [credentials] - The DeviceTokenCredentials object + */ +export function interactiveLogin (options?: InteractiveLoginOptions, callback); + +/** + * Provides a UserTokenCredentials object. This method is applicable only for organizational ids that are not 2FA enabled. + * Otherwise please use interactive login. + * + * @param {string} username The user name for the Organization Id account. + * + * @param {string} password The password for the Organization Id account. + * + * @param {LoginWithUsernamePasswordOptions} [options] The parameter options. + * + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {UserTokenCredentials} [credentials] - The UserTokenCredentials object + */ +export function loginWithUsernamePassword (username: string, password: string, options?: LoginWithUsernamePasswordOptions, callback); + + +/** + * Provides an ApplicationTokenCredentials object. + * + * @param {string} clientId The active directory application client id also known as the SPN (ServicePrincipal Name). + * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} + * for an example. + * + * @param {string} secret The application secret for the service principal. + * + * @param {string} domain The domain or tenant id containing this application. + * + * @param {AzureTokenCredentialsOptions} [options] The parameter options. + * + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {ApplicationTokenCredentials} [credentials] - The ApplicationTokenCredentials object + */ +export function loginWithServicePrincipalSecret (clientId: string, secret: string, domain: string, options?: AzureTokenCredentialsOptions, callback); \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js new file mode 100644 index 0000000000000..7aff354c5d5d6 --- /dev/null +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/login.js @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +var adal= require('adal-node'); +var async = require('async'); + +var azureConstants = require('./constants'); +var ApplicationTokenCredentials = require('./credentials/applicationTokenCredentials'); +var DeviceTokenCredentials = require('./credentials/deviceTokenCredentials'); +var UserTokenCredentials = require('./credentials/userTokenCredentials'); +var AzureEnvironment = require('./azureEnvironment'); + +function _createDeviceCredentials(tokenResponse) { + var options = {}; + options.environment = this.environment; + options.domain = this.domain; + options.clientId = this.clientId; + options.tokenCache = this.tokenCache; + options.username = tokenResponse.userId; + options.authorizationScheme = tokenResponse.tokenType; + var credentials = new DeviceTokenCredentials(options); + return credentials; +} + +function _turnOnLogging() { + var log = adal.Logging; + log.setLoggingOptions( + { + level : log.LOGGING_LEVEL.VERBOSE, + log : function (level, message, error) { + console.info(message); + if (error) { + console.error(error); + } + } + }); +} + +if (process.env['AZURE_ADAL_LOGGING_ENABLED']) { + _turnOnLogging(); +} + +/** + * Provides a url and code that needs to be copy and pasted in a browser and authenticated over there. If successful, the user will get a + * DeviceTokenCredentials object + * + * @param {object} [options] Object representing optional parameters. + * + * @param {string} [options.clientId] The active directory application client id. + * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} + * for an example. + * + * @param {string} [options.domain] The domain or tenant id containing this application. Default value is 'common' + * + * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. Default environment is "Public Azure". + * + * @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. + * + * @param {object} [options.language] The language code specifying how the message should be localized to. Default value 'en-us'. + * + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {DeviceTokenCredentials} [credentials] - The DeviceTokenCredentials object + */ +exports.interactive = function interactive(options, callback) { + if(!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + if (!options.environment) { + options.environment = AzureEnvironment.Azure; + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + + if (!options.tokenCache) { + options.tokenCache = new adal.MemoryCache(); + } + + if (!options.language) { + options.language = azureConstants.DEFAULT_LANGUAGE; + } + + this.environment = options.environment; + this.domain = options.domain; + this.clientId = options.clientId; + this.tokenCache = options.tokenCache; + this.language = options.language; + var authorityUrl = this.environment.activeDirectoryEndpointUrl + this.domain; + this.context = new adal.AuthenticationContext(authorityUrl, this.environment.validateAuthority, this.tokenCache); + var self = this; + async.waterfall([ + function (callback) { + self.context.acquireUserCode(self.environment.activeDirectoryResourceId, self.clientId, self.language, function (err, userCodeResponse) { + if (err) return callback(err); + console.log(userCodeResponse.message); + return callback(null, userCodeResponse); + }); + }, + function (userCodeResponse, callback) { + self.context.acquireTokenWithDeviceCode(self.environment.activeDirectoryResourceId, self.clientId, userCodeResponse, function (err, tokenResponse) { + if (err) return callback(err); + return callback(null, tokenResponse); + }); + } + ], function(err, tokenResponse) { + if (err) return callback(err); + return callback(null, _createDeviceCredentials.call(self, tokenResponse)); + }); +}; + +/** + * Provides a UserTokenCredentials object. This method is applicable only for organizational ids that are not 2FA enabled. + * Otherwise please use interactive login. + * + * @param {string} username The user name for the Organization Id account. + * @param {string} password The password for the Organization Id account. + * @param {object} [options] Object representing optional parameters. + * @param {string} [options.clientId] The active directory application client id. + * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} + * for an example. + * @param {string} [options.domain] The domain or tenant id containing this application. Default value 'common'. + * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. + * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. + * @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {UserTokenCredentials} [credentials] - The UserTokenCredentials object + */ +exports.withUsernamePassword = function withUsernamePassword(username, password, options, callback) { + if(!callback && typeof options === 'function') { + callback = options; + options = {}; + } + + if (!options.domain) { + options.domain = azureConstants.AAD_COMMON_TENANT; + } + + if (!options.clientId) { + options.clientId = azureConstants.DEFAULT_ADAL_CLIENT_ID; + } + var creds; + try { + creds = new UserTokenCredentials(options.clientId, options.domain, username, password, options); + } catch (err) { + return callback(err); + } + return callback(null, creds); +}; + +/** + * Provides an ApplicationTokenCredentials object. + * + * @param {string} clientId The active directory application client id also known as the SPN (ServicePrincipal Name). + * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net} + * for an example. + * @param {string} secret The application secret for the service principal. + * @param {string} domain The domain or tenant id containing this application. + * @param {object} [options] Object representing optional parameters. + * @param {AzureEnvironment} [options.environment] The azure environment to authenticate with. + * @param {string} [options.authorizationScheme] The authorization scheme. Default value is 'bearer'. + * @param {object} [options.tokenCache] The token cache. Default value is the MemoryCache object from adal. + * @param {function} callback + * + * @returns {function} callback(err, credentials) + * + * {Error} [err] - The Error object if an error occurred, null otherwise. + * + * {UserTokenCredentials} [credentials] - The UserTokenCredentials object + */ +exports.withServicePrincipalSecret = function withServicePrincipalSecret(clientId, secret, domain, options, callback) { + if(!callback && typeof options === 'function') { + callback = options; + options = {}; + } + var creds; + try { + creds = new ApplicationTokenCredentials(clientId, domain, secret, options); + } catch (err) { + return callback(err); + } + return callback(null, creds); +}; + +exports = module.exports; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js b/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js index ff592098b3ec8..62d4b7944c636 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/lib/msRestAzure.js @@ -5,10 +5,14 @@ exports.AzureServiceClient = require('./azureServiceClient'); exports.UserTokenCredentials = require('./credentials/userTokenCredentials'); exports.ApplicationTokenCredentials = require('./credentials/applicationTokenCredentials'); +exports.DeviceTokenCredentials = require('./credentials/deviceTokenCredentials'); exports.AzureEnvironment = require('./azureEnvironment'); exports.BaseResource = require('./baseResource'); exports.CloudError = require('./cloudError'); exports.TokenCredentials = require('ms-rest').TokenCredentials; -exports.generateUuid = require('./utils').generateUuid; +exports.generateUuid = require('./utils').generateUuid; +exports.interactiveLogin = require('./login').interactive; +exports.loginWithUsernamePassword = require('./login').withUsernamePassword; +exports.loginWithServicePrincipalSecret = require('./login').withServicePrincipalSecret; exports = module.exports; \ No newline at end of file diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/package.json b/ClientRuntimes/NodeJS/ms-rest-azure/package.json index cd4e61c7c9655..d6f7444e9f900 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/package.json +++ b/ClientRuntimes/NodeJS/ms-rest-azure/package.json @@ -5,7 +5,7 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/AutoRest" }, - "version": "1.13.1", + "version": "1.14.2", "description": "Client Runtime for Node.js Azure client libraries generated using AutoRest", "tags": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], "keywords": [ "node", "microsoft", "autorest", "azure", "clientruntime" ], @@ -17,8 +17,8 @@ "dependencies": { "async": "0.2.7", "uuid": "2.0.1", - "adal-node": "0.1.17", - "ms-rest": "^1.13.1", + "adal-node": "^0.1.17", + "ms-rest": "^1.14.2", "moment": "^2.6.0" }, "devDependencies": { diff --git a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js index 8e11e689690b7..b9e71b6134694 100644 --- a/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js +++ b/ClientRuntimes/NodeJS/ms-rest-azure/test/azureServiceClientTests.js @@ -10,7 +10,7 @@ var AzureServiceClient = require('../lib/azureServiceClient'); var LroStates = require('../lib/constants').LongRunningOperationStates; var msRest = require('ms-rest'); var UserTokenCredentials = require('../lib/credentials/userTokenCredentials'); -var credentials = new UserTokenCredentials('clientId', 'domain', 'username', 'password', 'clientredirecturi'); +var credentials = new UserTokenCredentials('clientId', 'domain', 'username', 'password'); describe('AzureServiceClient', function () { describe('Constructor intialization', function () { diff --git a/ClientRuntimes/NodeJS/ms-rest/README.md b/ClientRuntimes/NodeJS/ms-rest/README.md index 1da52bff1ac92..cf74c263c7df3 100644 --- a/ClientRuntimes/NodeJS/ms-rest/README.md +++ b/ClientRuntimes/NodeJS/ms-rest/README.md @@ -2,7 +2,7 @@ Infrastructure for serialization/deserialization, error handling, tracing, and http client pipeline configuration. Required by nodeJS client libraries generated using AutoRest. -- **Node.js version: 0.10.0 or higher** +- **Node.js version: 4.x.x or higher** ## How to Install diff --git a/ClientRuntimes/NodeJS/ms-rest/lib/constants.js b/ClientRuntimes/NodeJS/ms-rest/lib/constants.js index 42722e9342ccf..fa8a3137306b1 100644 --- a/ClientRuntimes/NodeJS/ms-rest/lib/constants.js +++ b/ClientRuntimes/NodeJS/ms-rest/lib/constants.js @@ -62,7 +62,9 @@ var Constants = { * @const * @type {string} */ - AUTHORIZATION: 'authorization' + AUTHORIZATION: 'authorization', + + AUTHORIZATION_SCHEME: 'Bearer' } }; diff --git a/ClientRuntimes/NodeJS/ms-rest/package.json b/ClientRuntimes/NodeJS/ms-rest/package.json index 656299783e9f9..f65673c6a39d6 100644 --- a/ClientRuntimes/NodeJS/ms-rest/package.json +++ b/ClientRuntimes/NodeJS/ms-rest/package.json @@ -5,15 +5,12 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/AutoRest" }, - "version": "1.13.1", + "version": "1.14.2", "description": "Client Runtime for Node.js client libraries generated using AutoRest", "tags": ["node", "microsoft", "autorest", "clientruntime"], "keywords": ["node", "microsoft", "autorest", "clientruntime"], "main": "./lib/msRest.js", "typings": "./lib/index.d.ts", - "engines": { - "node": ">= 0.10.0" - }, "license": "MIT", "dependencies": { "underscore": "^1.4.0", diff --git a/ClientRuntimes/Python/msrest/msrest/configuration.py b/ClientRuntimes/Python/msrest/msrest/configuration.py index 0c2ae4785d6ad..f9b4e06d20971 100644 --- a/ClientRuntimes/Python/msrest/msrest/configuration.py +++ b/ClientRuntimes/Python/msrest/msrest/configuration.py @@ -31,7 +31,7 @@ except ImportError: import ConfigParser as configparser from ConfigParser import NoOptionError -import sys +import platform import requests @@ -68,8 +68,9 @@ def __init__(self, base_url, filepath=None): self.redirect_policy = ClientRedirectPolicy() # User-Agent Header - self._user_agent = "python/{} requests/{} msrest/{}".format( - sys.version.split(' ')[0], + self._user_agent = "python/{} ({}) requests/{} msrest/{}".format( + platform.python_version(), + platform.platform(), requests.__version__, msrest_version) diff --git a/ClientRuntimes/Python/msrest/msrest/serialization.py b/ClientRuntimes/Python/msrest/msrest/serialization.py index 4675cd6aacee7..9dbae75a676db 100644 --- a/ClientRuntimes/Python/msrest/msrest/serialization.py +++ b/ClientRuntimes/Python/msrest/msrest/serialization.py @@ -25,10 +25,12 @@ # -------------------------------------------------------------------------- from base64 import b64decode, b64encode +import calendar import datetime import decimal from enum import Enum import json +import logging import re try: from urllib import quote @@ -49,6 +51,31 @@ except NameError: basestring = str +_LOGGER = logging.getLogger(__name__) + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() + class Model(object): """Mixin for all client request body/response body models to support @@ -67,7 +94,7 @@ def __init__(self, *args, **kwargs): def __eq__(self, other): """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ + return self.__class__.__dict__ == other.__class__.__dict__ return False def __ne__(self, other): @@ -112,6 +139,41 @@ def _classify(cls, response, objects): raise TypeError("Object cannot be classified futher.") +def _convert_to_datatype(data, data_type, localtypes): + if data is None: + return data + data_obj = localtypes.get(data_type.strip('{[]}')) + if data_obj: + if data_type.startswith('['): + data = [ + _convert_to_datatype( + param, data_type[1:-1], localtypes) for param in data + ] + elif data_type.startswith('{'): + data = { + key: _convert_to_datatype( + data[key], data_type[1:-1], localtypes) for key in data + } + elif issubclass(data_obj, Enum): + return data + elif not isinstance(data, data_obj): + result = { + key: _convert_to_datatype( + data[key], + data_obj._attribute_map[key]['type'], + localtypes) for key in data + } + data = data_obj(**result) + else: + try: + for attr, map in data._attribute_map.items(): + setattr(data, attr, _convert_to_datatype( + getattr(data, attr), map['type'], localtypes)) + except AttributeError: + pass + return data + + class Serializer(object): """Request object model serializer.""" @@ -135,19 +197,22 @@ class Serializer(object): } flattten = re.compile(r"(? 9999 or utc.tm_year < 1: raise OverflowError("Hit max or min date") @@ -560,6 +662,28 @@ def serialize_iso(attr, **kwargs): except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") class Deserializer(object): @@ -575,20 +699,22 @@ class Deserializer(object): '\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') flatten = re.compile(r"(?gulp test +### Running AutoRest +#### Command Line +After building, the `AutoRest.exe` executable will be output to the `/binaries/net45/` folder. You can run it with the command line options specified in the [Command Line Interface](./cli.md) documentation. + +#### Visual Studio +You can run (and debug) AutoRest by providing the command line parameters in the properties for the AutoRest project. To set these: +1. Open the properties for the AutoRest project. +2. Select the `Debug` tab. +3. Set the `Command line arguments` field in the `Start Options` section. +4. Build the entire solution to make sure the generators and modelers are built. +5. F5 the project. + +#### Troubleshooting + +#####If the Client Runtime project.json shows an error for Newtonsoft.Json, saying that the dependency does not support framework `.NETPortable,Version=4.5,Profile=111` +There is an issue with DNX 1.0.0-rc1 for optional frameworks: [https://github.com/aspnet/dnx/issues/2967](https://github.com/aspnet/dnx/issues/2967). If you have Xamarin files in the directory `C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile111\SupportedFrameworks`, then it will not be able to find the Newtonsoft.Json dependency. + +#####If the task runner window in Visual Studio does not show any tasks +Make sure that you have run `npm install` in the root folder. + +#####If `AutoRest.exe` complains about not having generators for each language +Make sure that you have built the entire `AutoRest.sln` solution. + +#####If you see the error `gulp is not recognized as an internal or external command` +`gulp` is located at `C:\Users\[user]\AppData\Roaming\npm\gulp` in Windows after you install it globally. + +#####If you see an error about the target framework not being available +Make sure that the correct DNX version is being used with `dnvm upgrade -r coreclr -arch x64`. + # Releasing AutoRest and ClientRuntimes - [ ] Merge pending PRs into the master branch diff --git a/Samples/azure-storage/Azure.Python/storagemanagementclient/__init__.py b/Samples/azure-storage/Azure.Python/storagemanagementclient/__init__.py index 8da05fb0ca8e6..4ef2ad5559905 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/__init__.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/__init__.py @@ -2,13 +2,10 @@ # -------------------------------------------------------------------------- # -------------------------------------------------------------------------- -from .storage_management_client import StorageManagementClient, StorageManagementClientConfiguration +from .storage_management_client import StorageManagementClient from .version import VERSION -__all__ = [ - 'StorageManagementClient', - 'StorageManagementClientConfiguration' -] +__all__ = ['StorageManagementClient'] __version__ = VERSION 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 00031c87fca75..5b0b67e876672 100644 --- a/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py +++ b/Samples/azure-storage/Azure.Python/storagemanagementclient/storage_management_client.py @@ -71,24 +71,47 @@ def __init__( class StorageManagementClient(object): """The Storage Management Client. - :param config: Configuration for client. - :type config: StorageManagementClientConfiguration + :ivar config: Configuration for client. + :vartype config: StorageManagementClientConfiguration :ivar storage_accounts: StorageAccounts operations :vartype storage_accounts: .operations.StorageAccountsOperations :ivar usage: Usage operations :vartype usage: .operations.UsageOperations + + :param credentials: Gets Azure subscription credentials. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Gets subscription credentials which uniquely + identify Microsoft Azure subscription. The subscription ID forms part of + the URI for every service call. + :type subscription_id: str + :param api_version: Client Api Version. + :type api_version: str + :param accept_language: Gets or sets the preferred language for the + response. + :type accept_language: str + :param long_running_operation_retry_timeout: Gets or sets the retry + timeout in seconds for Long Running Operations. Default value is 30. + :type long_running_operation_retry_timeout: int + :param generate_client_request_id: When set to true a unique + x-ms-client-request-id value is generated and included in each request. + Default is true. + :type generate_client_request_id: bool + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + 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): - self._client = ServiceClient(config.credentials, config) + self.config = StorageManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) + self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config self.storage_accounts = StorageAccountsOperations( self._client, self.config, self._serialize, self._deserialize) self.usage = UsageOperations( diff --git a/Samples/petstore/Python/swaggerpetstore/__init__.py b/Samples/petstore/Python/swaggerpetstore/__init__.py index 0caab4f5c7c79..06086d20d52d0 100644 --- a/Samples/petstore/Python/swaggerpetstore/__init__.py +++ b/Samples/petstore/Python/swaggerpetstore/__init__.py @@ -2,13 +2,10 @@ # -------------------------------------------------------------------------- # -------------------------------------------------------------------------- -from .swagger_petstore import SwaggerPetstore, SwaggerPetstoreConfiguration +from .swagger_petstore import SwaggerPetstore from .version import VERSION -__all__ = [ - 'SwaggerPetstore', - 'SwaggerPetstoreConfiguration' -] +__all__ = ['SwaggerPetstore'] __version__ = VERSION diff --git a/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py b/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py index 461a21d5e6993..ef020f9303a6c 100644 --- a/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py +++ b/Samples/petstore/Python/swaggerpetstore/swagger_petstore.py @@ -33,19 +33,23 @@ def __init__( class SwaggerPetstore(object): """This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters - :param config: Configuration for client. - :type config: SwaggerPetstoreConfiguration + :ivar config: Configuration for client. + :vartype config: SwaggerPetstoreConfiguration + + :param str base_url: Service URL + :param str filepath: Existing config """ - def __init__(self, config): + def __init__( + self, base_url=None, filepath=None): - self._client = ServiceClient(None, config) + self.config = SwaggerPetstoreConfiguration(base_url, filepath) + self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer() + self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.config = config def add_pet_using_byte_array( self, body=None, custom_headers={}, raw=False, **operation_config):