From 67246066a1735df6cdb4542ddf9a108bfb0c25b8 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 18 Jul 2022 02:20:20 -0700 Subject: [PATCH] [AutoRelease] t2-automation-2022-07-05-46277(Do not merge) (#25069) * code and test * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: PythonSdkPipelines Co-authored-by: zhenbiao wei <424401670@qq.com> Co-authored-by: Yuchao Yan --- .../azure-mgmt-automation/CHANGELOG.md | 40 + .../azure-mgmt-automation/MANIFEST.in | 1 + .../azure-mgmt-automation/_meta.json | 11 + .../azure/mgmt/automation/__init__.py | 12 +- .../mgmt/automation/_automation_client.py | 349 +- .../azure/mgmt/automation/_configuration.py | 24 +- .../azure/mgmt/automation/_patch.py | 19 + .../azure/mgmt/automation/_vendor.py | 45 + .../azure/mgmt/automation/_version.py | 2 +- .../azure/mgmt/automation/aio/__init__.py | 10 + .../mgmt/automation/aio/_automation_client.py | 338 +- .../mgmt/automation/aio/_configuration.py | 11 +- .../azure/mgmt/automation/aio/_patch.py | 19 + .../azure/mgmt/automation/aio/_vendor.py | 27 + .../automation/aio/operations/__init__.py | 61 +- .../aio/operations/_activity_operations.py | 193 +- ...ent_registration_information_operations.py | 180 +- .../_automation_account_operations.py | 472 +- .../_automation_client_operations.py | 100 + .../aio/operations/_certificate_operations.py | 404 +- .../aio/operations/_connection_operations.py | 404 +- .../operations/_connection_type_operations.py | 327 +- .../aio/operations/_credential_operations.py | 402 +- .../_dsc_compilation_job_operations.py | 398 +- .../_dsc_compilation_job_stream_operations.py | 107 +- .../_dsc_configuration_operations.py | 527 +- .../_dsc_node_configuration_operations.py | 411 +- .../aio/operations/_dsc_node_operations.py | 348 +- .../aio/operations/_fields_operations.py | 129 +- ..._hybrid_runbook_worker_group_operations.py | 412 +- .../_hybrid_runbook_workers_operations.py | 459 ++ .../aio/operations/_job_operations.py | 598 +- .../operations/_job_schedule_operations.py | 333 +- .../aio/operations/_job_stream_operations.py | 210 +- .../aio/operations/_keys_operations.py | 105 +- .../_linked_workspace_operations.py | 105 +- .../aio/operations/_module_operations.py | 398 +- .../_node_count_information_operations.py | 107 +- .../operations/_node_reports_operations.py | 272 +- .../_object_data_types_operations.py | 214 +- .../automation/aio/operations/_operations.py | 109 +- .../mgmt/automation/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 490 ++ .../_private_link_resources_operations.py | 138 + .../operations/_python2_package_operations.py | 398 +- .../operations/_runbook_draft_operations.py | 391 +- .../aio/operations/_runbook_operations.py | 579 +- .../aio/operations/_schedule_operations.py | 401 +- ...e_configuration_machine_runs_operations.py | 197 +- ...re_update_configuration_runs_operations.py | 197 +- ...ftware_update_configurations_operations.py | 332 +- .../operations/_source_control_operations.py | 410 +- .../_source_control_sync_job_operations.py | 281 +- ...rce_control_sync_job_streams_operations.py | 207 +- .../aio/operations/_statistics_operations.py | 132 +- .../aio/operations/_test_job_operations.py | 361 +- .../_test_job_streams_operations.py | 199 +- .../aio/operations/_usages_operations.py | 120 +- .../aio/operations/_variable_operations.py | 401 +- .../aio/operations/_watcher_operations.py | 525 +- .../aio/operations/_webhook_operations.py | 463 +- .../azure/mgmt/automation/models/__init__.py | 540 +- .../models/_automation_client_enums.py | 122 +- .../azure/mgmt/automation/models/_models.py | 6099 ----------------- .../mgmt/automation/models/_models_py3.py | 5488 +++++++++++---- .../azure/mgmt/automation/models/_patch.py | 19 + .../mgmt/automation/operations/__init__.py | 61 +- .../operations/_activity_operations.py | 287 +- ...ent_registration_information_operations.py | 272 +- .../_automation_account_operations.py | 737 +- .../_automation_client_operations.py | 147 + .../operations/_certificate_operations.py | 658 +- .../operations/_connection_operations.py | 658 +- .../operations/_connection_type_operations.py | 527 +- .../operations/_credential_operations.py | 656 +- .../_dsc_compilation_job_operations.py | 613 +- .../_dsc_compilation_job_stream_operations.py | 167 +- .../_dsc_configuration_operations.py | 850 ++- .../_dsc_node_configuration_operations.py | 642 +- .../operations/_dsc_node_operations.py | 569 +- .../operations/_fields_operations.py | 190 +- ..._hybrid_runbook_worker_group_operations.py | 668 +- .../_hybrid_runbook_workers_operations.py | 683 ++ .../automation/operations/_job_operations.py | 1045 ++- .../operations/_job_schedule_operations.py | 539 +- .../operations/_job_stream_operations.py | 321 +- .../automation/operations/_keys_operations.py | 161 +- .../_linked_workspace_operations.py | 161 +- .../operations/_module_operations.py | 655 +- .../_node_count_information_operations.py | 167 +- .../operations/_node_reports_operations.py | 434 +- .../_object_data_types_operations.py | 310 +- .../mgmt/automation/operations/_operations.py | 140 +- .../mgmt/automation/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 652 ++ .../_private_link_resources_operations.py | 177 + .../operations/_python2_package_operations.py | 655 +- .../operations/_runbook_draft_operations.py | 606 +- .../operations/_runbook_operations.py | 936 ++- .../operations/_schedule_operations.py | 655 +- ...e_configuration_machine_runs_operations.py | 312 +- ...re_update_configuration_runs_operations.py | 312 +- ...ftware_update_configurations_operations.py | 564 +- .../operations/_source_control_operations.py | 670 +- .../_source_control_sync_job_operations.py | 454 +- ...rce_control_sync_job_streams_operations.py | 318 +- .../operations/_statistics_operations.py | 191 +- .../operations/_test_job_operations.py | 619 +- .../_test_job_streams_operations.py | 299 +- .../operations/_usages_operations.py | 176 +- .../operations/_variable_operations.py | 655 +- .../operations/_watcher_operations.py | 881 ++- .../operations/_webhook_operations.py | 767 ++- sdk/automation/azure-mgmt-automation/setup.py | 6 +- ...stMgmtAutomationClienttest_automation.json | 96 +- shared_requirements.txt | 2 + 116 files changed, 29229 insertions(+), 20313 deletions(-) create mode 100644 sdk/automation/azure-mgmt-automation/_meta.json create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_patch.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py delete mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_patch.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_patch.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py diff --git a/sdk/automation/azure-mgmt-automation/CHANGELOG.md b/sdk/automation/azure-mgmt-automation/CHANGELOG.md index 6826913cec8d..70720d09a3ce 100644 --- a/sdk/automation/azure-mgmt-automation/CHANGELOG.md +++ b/sdk/automation/azure-mgmt-automation/CHANGELOG.md @@ -1,5 +1,45 @@ # Release History +## 1.1.0b2 (2022-07-18) + +**Features** + + - Added operation HybridRunbookWorkerGroupOperations.create + - Added operation group AutomationClientOperationsMixin + - Added operation group HybridRunbookWorkersOperations + - Added operation group PrivateEndpointConnectionsOperations + - Added operation group PrivateLinkResourcesOperations + - Model AutomationAccount has a new parameter automation_hybrid_service_url + - Model AutomationAccount has a new parameter disable_local_auth + - Model AutomationAccount has a new parameter encryption + - Model AutomationAccount has a new parameter identity + - Model AutomationAccount has a new parameter private_endpoint_connections + - Model AutomationAccount has a new parameter public_network_access + - Model AutomationAccount has a new parameter system_data + - Model AutomationAccountCreateOrUpdateParameters has a new parameter disable_local_auth + - Model AutomationAccountCreateOrUpdateParameters has a new parameter encryption + - Model AutomationAccountCreateOrUpdateParameters has a new parameter identity + - Model AutomationAccountCreateOrUpdateParameters has a new parameter public_network_access + - Model AutomationAccountUpdateParameters has a new parameter disable_local_auth + - Model AutomationAccountUpdateParameters has a new parameter encryption + - Model AutomationAccountUpdateParameters has a new parameter identity + - Model AutomationAccountUpdateParameters has a new parameter public_network_access + - Model HybridRunbookWorker has a new parameter id + - Model HybridRunbookWorker has a new parameter registered_date_time + - Model HybridRunbookWorker has a new parameter system_data + - Model HybridRunbookWorker has a new parameter type + - Model HybridRunbookWorker has a new parameter vm_resource_id + - Model HybridRunbookWorker has a new parameter worker_name + - Model HybridRunbookWorker has a new parameter worker_type + - Model HybridRunbookWorkerGroup has a new parameter system_data + - Model HybridRunbookWorkerGroup has a new parameter type + - Operation DscConfigurationOperations.create_or_update has a new optional and keyword-only parameter content_type + - Operation DscConfigurationOperations.update has a new optional and keyword-only parameter content_type + +**Breaking changes** + + - Model HybridRunbookWorker no longer has parameter registration_time + ## 1.1.0b1 (2021-03-16) **Features** diff --git a/sdk/automation/azure-mgmt-automation/MANIFEST.in b/sdk/automation/azure-mgmt-automation/MANIFEST.in index 2c31e8da0cb1..628e17f9e09a 100644 --- a/sdk/automation/azure-mgmt-automation/MANIFEST.in +++ b/sdk/automation/azure-mgmt-automation/MANIFEST.in @@ -4,3 +4,4 @@ include *.md include azure/__init__.py include azure/mgmt/__init__.py include LICENSE +include azure/mgmt/automation/py.typed diff --git a/sdk/automation/azure-mgmt-automation/_meta.json b/sdk/automation/azure-mgmt-automation/_meta.json new file mode 100644 index 000000000000..d0d76552566a --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "fc2245b8f0fe6f17628e3b5a306b4b150c73cff0", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/automation/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/automation/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py index 29580d4d1d84..a5838dfd5d0e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AutomationClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['AutomationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py index aa9b40978ef3..c555af38b201 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py @@ -6,103 +6,59 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AutomationClientConfiguration -from .operations import RunbookDraftOperations -from .operations import RunbookOperations -from .operations import TestJobStreamsOperations -from .operations import TestJobOperations -from .operations import Python2PackageOperations -from .operations import AgentRegistrationInformationOperations -from .operations import DscNodeOperations -from .operations import NodeReportsOperations -from .operations import DscCompilationJobOperations -from .operations import DscCompilationJobStreamOperations -from .operations import DscNodeConfigurationOperations -from .operations import NodeCountInformationOperations -from .operations import SoftwareUpdateConfigurationRunsOperations -from .operations import SoftwareUpdateConfigurationMachineRunsOperations -from .operations import SourceControlOperations -from .operations import SourceControlSyncJobOperations -from .operations import SourceControlSyncJobStreamsOperations -from .operations import JobOperations -from .operations import JobStreamOperations -from .operations import AutomationAccountOperations -from .operations import StatisticsOperations -from .operations import UsagesOperations -from .operations import KeysOperations -from .operations import CertificateOperations -from .operations import ConnectionOperations -from .operations import ConnectionTypeOperations -from .operations import CredentialOperations -from .operations import DscConfigurationOperations -from .operations import SoftwareUpdateConfigurationsOperations -from .operations import HybridRunbookWorkerGroupOperations -from .operations import JobScheduleOperations -from .operations import LinkedWorkspaceOperations -from .operations import ActivityOperations -from .operations import ModuleOperations -from .operations import ObjectDataTypesOperations -from .operations import FieldsOperations -from .operations import Operations -from .operations import ScheduleOperations -from .operations import VariableOperations -from .operations import WatcherOperations -from .operations import WebhookOperations from . import models +from ._configuration import AutomationClientConfiguration +from .operations import ActivityOperations, AgentRegistrationInformationOperations, AutomationAccountOperations, AutomationClientOperationsMixin, CertificateOperations, ConnectionOperations, ConnectionTypeOperations, CredentialOperations, DscCompilationJobOperations, DscCompilationJobStreamOperations, DscConfigurationOperations, DscNodeConfigurationOperations, DscNodeOperations, FieldsOperations, HybridRunbookWorkerGroupOperations, HybridRunbookWorkersOperations, JobOperations, JobScheduleOperations, JobStreamOperations, KeysOperations, LinkedWorkspaceOperations, ModuleOperations, NodeCountInformationOperations, NodeReportsOperations, ObjectDataTypesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, RunbookDraftOperations, RunbookOperations, ScheduleOperations, SoftwareUpdateConfigurationMachineRunsOperations, SoftwareUpdateConfigurationRunsOperations, SoftwareUpdateConfigurationsOperations, SourceControlOperations, SourceControlSyncJobOperations, SourceControlSyncJobStreamsOperations, StatisticsOperations, TestJobOperations, TestJobStreamsOperations, UsagesOperations, VariableOperations, WatcherOperations, WebhookOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Automation Client. - :ivar runbook_draft: RunbookDraftOperations operations - :vartype runbook_draft: azure.mgmt.automation.operations.RunbookDraftOperations - :ivar runbook: RunbookOperations operations - :vartype runbook: azure.mgmt.automation.operations.RunbookOperations - :ivar test_job_streams: TestJobStreamsOperations operations - :vartype test_job_streams: azure.mgmt.automation.operations.TestJobStreamsOperations - :ivar test_job: TestJobOperations operations - :vartype test_job: azure.mgmt.automation.operations.TestJobOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.automation.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.automation.operations.PrivateLinkResourcesOperations :ivar python2_package: Python2PackageOperations operations :vartype python2_package: azure.mgmt.automation.operations.Python2PackageOperations :ivar agent_registration_information: AgentRegistrationInformationOperations operations - :vartype agent_registration_information: azure.mgmt.automation.operations.AgentRegistrationInformationOperations + :vartype agent_registration_information: + azure.mgmt.automation.operations.AgentRegistrationInformationOperations :ivar dsc_node: DscNodeOperations operations :vartype dsc_node: azure.mgmt.automation.operations.DscNodeOperations :ivar node_reports: NodeReportsOperations operations :vartype node_reports: azure.mgmt.automation.operations.NodeReportsOperations + :ivar dsc_node_configuration: DscNodeConfigurationOperations operations + :vartype dsc_node_configuration: + azure.mgmt.automation.operations.DscNodeConfigurationOperations :ivar dsc_compilation_job: DscCompilationJobOperations operations :vartype dsc_compilation_job: azure.mgmt.automation.operations.DscCompilationJobOperations :ivar dsc_compilation_job_stream: DscCompilationJobStreamOperations operations - :vartype dsc_compilation_job_stream: azure.mgmt.automation.operations.DscCompilationJobStreamOperations - :ivar dsc_node_configuration: DscNodeConfigurationOperations operations - :vartype dsc_node_configuration: azure.mgmt.automation.operations.DscNodeConfigurationOperations + :vartype dsc_compilation_job_stream: + azure.mgmt.automation.operations.DscCompilationJobStreamOperations :ivar node_count_information: NodeCountInformationOperations operations - :vartype node_count_information: azure.mgmt.automation.operations.NodeCountInformationOperations - :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations - :vartype software_update_configuration_runs: azure.mgmt.automation.operations.SoftwareUpdateConfigurationRunsOperations - :ivar software_update_configuration_machine_runs: SoftwareUpdateConfigurationMachineRunsOperations operations - :vartype software_update_configuration_machine_runs: azure.mgmt.automation.operations.SoftwareUpdateConfigurationMachineRunsOperations + :vartype node_count_information: + azure.mgmt.automation.operations.NodeCountInformationOperations :ivar source_control: SourceControlOperations operations :vartype source_control: azure.mgmt.automation.operations.SourceControlOperations :ivar source_control_sync_job: SourceControlSyncJobOperations operations - :vartype source_control_sync_job: azure.mgmt.automation.operations.SourceControlSyncJobOperations + :vartype source_control_sync_job: + azure.mgmt.automation.operations.SourceControlSyncJobOperations :ivar source_control_sync_job_streams: SourceControlSyncJobStreamsOperations operations - :vartype source_control_sync_job_streams: azure.mgmt.automation.operations.SourceControlSyncJobStreamsOperations - :ivar job: JobOperations operations - :vartype job: azure.mgmt.automation.operations.JobOperations - :ivar job_stream: JobStreamOperations operations - :vartype job_stream: azure.mgmt.automation.operations.JobStreamOperations + :vartype source_control_sync_job_streams: + azure.mgmt.automation.operations.SourceControlSyncJobStreamsOperations :ivar automation_account: AutomationAccountOperations operations :vartype automation_account: azure.mgmt.automation.operations.AutomationAccountOperations :ivar statistics: StatisticsOperations operations @@ -119,12 +75,9 @@ class AutomationClient(object): :vartype connection_type: azure.mgmt.automation.operations.ConnectionTypeOperations :ivar credential: CredentialOperations operations :vartype credential: azure.mgmt.automation.operations.CredentialOperations - :ivar dsc_configuration: DscConfigurationOperations operations - :vartype dsc_configuration: azure.mgmt.automation.operations.DscConfigurationOperations - :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations - :vartype software_update_configurations: azure.mgmt.automation.operations.SoftwareUpdateConfigurationsOperations :ivar hybrid_runbook_worker_group: HybridRunbookWorkerGroupOperations operations - :vartype hybrid_runbook_worker_group: azure.mgmt.automation.operations.HybridRunbookWorkerGroupOperations + :vartype hybrid_runbook_worker_group: + azure.mgmt.automation.operations.HybridRunbookWorkerGroupOperations :ivar job_schedule: JobScheduleOperations operations :vartype job_schedule: azure.mgmt.automation.operations.JobScheduleOperations :ivar linked_workspace: LinkedWorkspaceOperations operations @@ -137,123 +90,227 @@ class AutomationClient(object): :vartype object_data_types: azure.mgmt.automation.operations.ObjectDataTypesOperations :ivar fields: FieldsOperations operations :vartype fields: azure.mgmt.automation.operations.FieldsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.automation.operations.Operations :ivar schedule: ScheduleOperations operations :vartype schedule: azure.mgmt.automation.operations.ScheduleOperations :ivar variable: VariableOperations operations :vartype variable: azure.mgmt.automation.operations.VariableOperations :ivar watcher: WatcherOperations operations :vartype watcher: azure.mgmt.automation.operations.WatcherOperations + :ivar dsc_configuration: DscConfigurationOperations operations + :vartype dsc_configuration: azure.mgmt.automation.operations.DscConfigurationOperations + :ivar job: JobOperations operations + :vartype job: azure.mgmt.automation.operations.JobOperations + :ivar job_stream: JobStreamOperations operations + :vartype job_stream: azure.mgmt.automation.operations.JobStreamOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.automation.operations.Operations + :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations + :vartype software_update_configurations: + azure.mgmt.automation.operations.SoftwareUpdateConfigurationsOperations + :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations + :vartype software_update_configuration_runs: + azure.mgmt.automation.operations.SoftwareUpdateConfigurationRunsOperations + :ivar software_update_configuration_machine_runs: + SoftwareUpdateConfigurationMachineRunsOperations operations + :vartype software_update_configuration_machine_runs: + azure.mgmt.automation.operations.SoftwareUpdateConfigurationMachineRunsOperations + :ivar runbook_draft: RunbookDraftOperations operations + :vartype runbook_draft: azure.mgmt.automation.operations.RunbookDraftOperations + :ivar runbook: RunbookOperations operations + :vartype runbook: azure.mgmt.automation.operations.RunbookOperations + :ivar test_job_streams: TestJobStreamsOperations operations + :vartype test_job_streams: azure.mgmt.automation.operations.TestJobStreamsOperations + :ivar test_job: TestJobOperations operations + :vartype test_job: azure.mgmt.automation.operations.TestJobOperations :ivar webhook: WebhookOperations operations :vartype webhook: azure.mgmt.automation.operations.WebhookOperations + :ivar hybrid_runbook_workers: HybridRunbookWorkersOperations operations + :vartype hybrid_runbook_workers: + azure.mgmt.automation.operations.HybridRunbookWorkersOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomationClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AutomationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - - self.runbook_draft = RunbookDraftOperations( - self._client, self._config, self._serialize, self._deserialize) - self.runbook = RunbookOperations( - self._client, self._config, self._serialize, self._deserialize) - self.test_job_streams = TestJobStreamsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.test_job = TestJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.python2_package = Python2PackageOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.agent_registration_information = AgentRegistrationInformationOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_node = DscNodeOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.node_reports = NodeReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.dsc_node_configuration = DscNodeConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_compilation_job = DscCompilationJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_compilation_job_stream = DscCompilationJobStreamOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_node_configuration = DscNodeConfigurationOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.node_count_information = NodeCountInformationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configuration_runs = SoftwareUpdateConfigurationRunsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configuration_machine_runs = SoftwareUpdateConfigurationMachineRunsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control = SourceControlOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control_sync_job = SourceControlSyncJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control_sync_job_streams = SourceControlSyncJobStreamsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job = JobOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_stream = JobStreamOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.automation_account = AutomationAccountOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.statistics = StatisticsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.keys = KeysOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.certificate = CertificateOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.connection = ConnectionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.connection_type = ConnectionTypeOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.credential = CredentialOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_configuration = DscConfigurationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configurations = SoftwareUpdateConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.job_schedule = JobScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.linked_workspace = LinkedWorkspaceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.activity = ActivityOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.module = ModuleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.object_data_types = ObjectDataTypesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.fields = FieldsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.schedule = ScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.variable = VariableOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.watcher = WatcherOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.dsc_configuration = DscConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.job = JobOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.job_stream = JobStreamOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configurations = SoftwareUpdateConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configuration_runs = SoftwareUpdateConfigurationRunsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configuration_machine_runs = SoftwareUpdateConfigurationMachineRunsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.runbook_draft = RunbookDraftOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.runbook = RunbookOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_job_streams = TestJobStreamsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_job = TestJobOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.webhook = WebhookOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.hybrid_runbook_workers = HybridRunbookWorkersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py index b9e9ba1a6151..4d1356d8bcfa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AutomationClientConfiguration(Configuration): +class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -29,22 +27,22 @@ class AutomationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AutomationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py new file mode 100644 index 000000000000..f3ab7d777870 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import AutomationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: AutomationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py index 653b73a4a199..f1fb63697cf5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b1" +VERSION = "1.1.0b2" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/__init__.py index c537136a35f8..dde67942a458 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/__init__.py @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._automation_client import AutomationClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['AutomationClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py index 0468a4e97c2e..9e71c6bbdaf2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py @@ -6,101 +6,59 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AutomationClientConfiguration -from .operations import RunbookDraftOperations -from .operations import RunbookOperations -from .operations import TestJobStreamsOperations -from .operations import TestJobOperations -from .operations import Python2PackageOperations -from .operations import AgentRegistrationInformationOperations -from .operations import DscNodeOperations -from .operations import NodeReportsOperations -from .operations import DscCompilationJobOperations -from .operations import DscCompilationJobStreamOperations -from .operations import DscNodeConfigurationOperations -from .operations import NodeCountInformationOperations -from .operations import SoftwareUpdateConfigurationRunsOperations -from .operations import SoftwareUpdateConfigurationMachineRunsOperations -from .operations import SourceControlOperations -from .operations import SourceControlSyncJobOperations -from .operations import SourceControlSyncJobStreamsOperations -from .operations import JobOperations -from .operations import JobStreamOperations -from .operations import AutomationAccountOperations -from .operations import StatisticsOperations -from .operations import UsagesOperations -from .operations import KeysOperations -from .operations import CertificateOperations -from .operations import ConnectionOperations -from .operations import ConnectionTypeOperations -from .operations import CredentialOperations -from .operations import DscConfigurationOperations -from .operations import SoftwareUpdateConfigurationsOperations -from .operations import HybridRunbookWorkerGroupOperations -from .operations import JobScheduleOperations -from .operations import LinkedWorkspaceOperations -from .operations import ActivityOperations -from .operations import ModuleOperations -from .operations import ObjectDataTypesOperations -from .operations import FieldsOperations -from .operations import Operations -from .operations import ScheduleOperations -from .operations import VariableOperations -from .operations import WatcherOperations -from .operations import WebhookOperations from .. import models +from ._configuration import AutomationClientConfiguration +from .operations import ActivityOperations, AgentRegistrationInformationOperations, AutomationAccountOperations, AutomationClientOperationsMixin, CertificateOperations, ConnectionOperations, ConnectionTypeOperations, CredentialOperations, DscCompilationJobOperations, DscCompilationJobStreamOperations, DscConfigurationOperations, DscNodeConfigurationOperations, DscNodeOperations, FieldsOperations, HybridRunbookWorkerGroupOperations, HybridRunbookWorkersOperations, JobOperations, JobScheduleOperations, JobStreamOperations, KeysOperations, LinkedWorkspaceOperations, ModuleOperations, NodeCountInformationOperations, NodeReportsOperations, ObjectDataTypesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, RunbookDraftOperations, RunbookOperations, ScheduleOperations, SoftwareUpdateConfigurationMachineRunsOperations, SoftwareUpdateConfigurationRunsOperations, SoftwareUpdateConfigurationsOperations, SourceControlOperations, SourceControlSyncJobOperations, SourceControlSyncJobStreamsOperations, StatisticsOperations, TestJobOperations, TestJobStreamsOperations, UsagesOperations, VariableOperations, WatcherOperations, WebhookOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Automation Client. - :ivar runbook_draft: RunbookDraftOperations operations - :vartype runbook_draft: azure.mgmt.automation.aio.operations.RunbookDraftOperations - :ivar runbook: RunbookOperations operations - :vartype runbook: azure.mgmt.automation.aio.operations.RunbookOperations - :ivar test_job_streams: TestJobStreamsOperations operations - :vartype test_job_streams: azure.mgmt.automation.aio.operations.TestJobStreamsOperations - :ivar test_job: TestJobOperations operations - :vartype test_job: azure.mgmt.automation.aio.operations.TestJobOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.automation.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.automation.aio.operations.PrivateLinkResourcesOperations :ivar python2_package: Python2PackageOperations operations :vartype python2_package: azure.mgmt.automation.aio.operations.Python2PackageOperations :ivar agent_registration_information: AgentRegistrationInformationOperations operations - :vartype agent_registration_information: azure.mgmt.automation.aio.operations.AgentRegistrationInformationOperations + :vartype agent_registration_information: + azure.mgmt.automation.aio.operations.AgentRegistrationInformationOperations :ivar dsc_node: DscNodeOperations operations :vartype dsc_node: azure.mgmt.automation.aio.operations.DscNodeOperations :ivar node_reports: NodeReportsOperations operations :vartype node_reports: azure.mgmt.automation.aio.operations.NodeReportsOperations + :ivar dsc_node_configuration: DscNodeConfigurationOperations operations + :vartype dsc_node_configuration: + azure.mgmt.automation.aio.operations.DscNodeConfigurationOperations :ivar dsc_compilation_job: DscCompilationJobOperations operations :vartype dsc_compilation_job: azure.mgmt.automation.aio.operations.DscCompilationJobOperations :ivar dsc_compilation_job_stream: DscCompilationJobStreamOperations operations - :vartype dsc_compilation_job_stream: azure.mgmt.automation.aio.operations.DscCompilationJobStreamOperations - :ivar dsc_node_configuration: DscNodeConfigurationOperations operations - :vartype dsc_node_configuration: azure.mgmt.automation.aio.operations.DscNodeConfigurationOperations + :vartype dsc_compilation_job_stream: + azure.mgmt.automation.aio.operations.DscCompilationJobStreamOperations :ivar node_count_information: NodeCountInformationOperations operations - :vartype node_count_information: azure.mgmt.automation.aio.operations.NodeCountInformationOperations - :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations - :vartype software_update_configuration_runs: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationRunsOperations - :ivar software_update_configuration_machine_runs: SoftwareUpdateConfigurationMachineRunsOperations operations - :vartype software_update_configuration_machine_runs: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationMachineRunsOperations + :vartype node_count_information: + azure.mgmt.automation.aio.operations.NodeCountInformationOperations :ivar source_control: SourceControlOperations operations :vartype source_control: azure.mgmt.automation.aio.operations.SourceControlOperations :ivar source_control_sync_job: SourceControlSyncJobOperations operations - :vartype source_control_sync_job: azure.mgmt.automation.aio.operations.SourceControlSyncJobOperations + :vartype source_control_sync_job: + azure.mgmt.automation.aio.operations.SourceControlSyncJobOperations :ivar source_control_sync_job_streams: SourceControlSyncJobStreamsOperations operations - :vartype source_control_sync_job_streams: azure.mgmt.automation.aio.operations.SourceControlSyncJobStreamsOperations - :ivar job: JobOperations operations - :vartype job: azure.mgmt.automation.aio.operations.JobOperations - :ivar job_stream: JobStreamOperations operations - :vartype job_stream: azure.mgmt.automation.aio.operations.JobStreamOperations + :vartype source_control_sync_job_streams: + azure.mgmt.automation.aio.operations.SourceControlSyncJobStreamsOperations :ivar automation_account: AutomationAccountOperations operations :vartype automation_account: azure.mgmt.automation.aio.operations.AutomationAccountOperations :ivar statistics: StatisticsOperations operations @@ -117,12 +75,9 @@ class AutomationClient(object): :vartype connection_type: azure.mgmt.automation.aio.operations.ConnectionTypeOperations :ivar credential: CredentialOperations operations :vartype credential: azure.mgmt.automation.aio.operations.CredentialOperations - :ivar dsc_configuration: DscConfigurationOperations operations - :vartype dsc_configuration: azure.mgmt.automation.aio.operations.DscConfigurationOperations - :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations - :vartype software_update_configurations: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationsOperations :ivar hybrid_runbook_worker_group: HybridRunbookWorkerGroupOperations operations - :vartype hybrid_runbook_worker_group: azure.mgmt.automation.aio.operations.HybridRunbookWorkerGroupOperations + :vartype hybrid_runbook_worker_group: + azure.mgmt.automation.aio.operations.HybridRunbookWorkerGroupOperations :ivar job_schedule: JobScheduleOperations operations :vartype job_schedule: azure.mgmt.automation.aio.operations.JobScheduleOperations :ivar linked_workspace: LinkedWorkspaceOperations operations @@ -135,122 +90,227 @@ class AutomationClient(object): :vartype object_data_types: azure.mgmt.automation.aio.operations.ObjectDataTypesOperations :ivar fields: FieldsOperations operations :vartype fields: azure.mgmt.automation.aio.operations.FieldsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.automation.aio.operations.Operations :ivar schedule: ScheduleOperations operations :vartype schedule: azure.mgmt.automation.aio.operations.ScheduleOperations :ivar variable: VariableOperations operations :vartype variable: azure.mgmt.automation.aio.operations.VariableOperations :ivar watcher: WatcherOperations operations :vartype watcher: azure.mgmt.automation.aio.operations.WatcherOperations + :ivar dsc_configuration: DscConfigurationOperations operations + :vartype dsc_configuration: azure.mgmt.automation.aio.operations.DscConfigurationOperations + :ivar job: JobOperations operations + :vartype job: azure.mgmt.automation.aio.operations.JobOperations + :ivar job_stream: JobStreamOperations operations + :vartype job_stream: azure.mgmt.automation.aio.operations.JobStreamOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.automation.aio.operations.Operations + :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations + :vartype software_update_configurations: + azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationsOperations + :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations + :vartype software_update_configuration_runs: + azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationRunsOperations + :ivar software_update_configuration_machine_runs: + SoftwareUpdateConfigurationMachineRunsOperations operations + :vartype software_update_configuration_machine_runs: + azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationMachineRunsOperations + :ivar runbook_draft: RunbookDraftOperations operations + :vartype runbook_draft: azure.mgmt.automation.aio.operations.RunbookDraftOperations + :ivar runbook: RunbookOperations operations + :vartype runbook: azure.mgmt.automation.aio.operations.RunbookOperations + :ivar test_job_streams: TestJobStreamsOperations operations + :vartype test_job_streams: azure.mgmt.automation.aio.operations.TestJobStreamsOperations + :ivar test_job: TestJobOperations operations + :vartype test_job: azure.mgmt.automation.aio.operations.TestJobOperations :ivar webhook: WebhookOperations operations :vartype webhook: azure.mgmt.automation.aio.operations.WebhookOperations + :ivar hybrid_runbook_workers: HybridRunbookWorkersOperations operations + :vartype hybrid_runbook_workers: + azure.mgmt.automation.aio.operations.HybridRunbookWorkersOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomationClientConfiguration(credential, subscription_id, **kwargs) + self._config = AutomationClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - - self.runbook_draft = RunbookDraftOperations( - self._client, self._config, self._serialize, self._deserialize) - self.runbook = RunbookOperations( - self._client, self._config, self._serialize, self._deserialize) - self.test_job_streams = TestJobStreamsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.test_job = TestJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.python2_package = Python2PackageOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.agent_registration_information = AgentRegistrationInformationOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_node = DscNodeOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.node_reports = NodeReportsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.dsc_node_configuration = DscNodeConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_compilation_job = DscCompilationJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.dsc_compilation_job_stream = DscCompilationJobStreamOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_node_configuration = DscNodeConfigurationOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.node_count_information = NodeCountInformationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configuration_runs = SoftwareUpdateConfigurationRunsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configuration_machine_runs = SoftwareUpdateConfigurationMachineRunsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control = SourceControlOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control_sync_job = SourceControlSyncJobOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.source_control_sync_job_streams = SourceControlSyncJobStreamsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job = JobOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_stream = JobStreamOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.automation_account = AutomationAccountOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.statistics = StatisticsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.keys = KeysOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.certificate = CertificateOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.connection = ConnectionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.connection_type = ConnectionTypeOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.credential = CredentialOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_configuration = DscConfigurationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_update_configurations = SoftwareUpdateConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.job_schedule = JobScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.linked_workspace = LinkedWorkspaceOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.activity = ActivityOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.module = ModuleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.object_data_types = ObjectDataTypesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.fields = FieldsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.schedule = ScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.variable = VariableOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.watcher = WatcherOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.dsc_configuration = DscConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.job = JobOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.job_stream = JobStreamOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configurations = SoftwareUpdateConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configuration_runs = SoftwareUpdateConfigurationRunsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.software_update_configuration_machine_runs = SoftwareUpdateConfigurationMachineRunsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.runbook_draft = RunbookDraftOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.runbook = RunbookOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_job_streams = TestJobStreamsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_job = TestJobOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.webhook = WebhookOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.hybrid_runbook_workers = HybridRunbookWorkersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py index dce38b50c718..a8ad2e83bdfc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AutomationClientConfiguration(Configuration): +class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -27,7 +27,8 @@ class AutomationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 """ @@ -37,11 +38,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AutomationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py new file mode 100644 index 000000000000..a8340cad02da --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import AutomationClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: AutomationClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py index d7371312a9c8..e8ed3f355edf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/__init__.py @@ -6,25 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._runbook_draft_operations import RunbookDraftOperations -from ._runbook_operations import RunbookOperations -from ._test_job_streams_operations import TestJobStreamsOperations -from ._test_job_operations import TestJobOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._python2_package_operations import Python2PackageOperations from ._agent_registration_information_operations import AgentRegistrationInformationOperations from ._dsc_node_operations import DscNodeOperations from ._node_reports_operations import NodeReportsOperations +from ._dsc_node_configuration_operations import DscNodeConfigurationOperations from ._dsc_compilation_job_operations import DscCompilationJobOperations from ._dsc_compilation_job_stream_operations import DscCompilationJobStreamOperations -from ._dsc_node_configuration_operations import DscNodeConfigurationOperations from ._node_count_information_operations import NodeCountInformationOperations -from ._software_update_configuration_runs_operations import SoftwareUpdateConfigurationRunsOperations -from ._software_update_configuration_machine_runs_operations import SoftwareUpdateConfigurationMachineRunsOperations from ._source_control_operations import SourceControlOperations from ._source_control_sync_job_operations import SourceControlSyncJobOperations from ._source_control_sync_job_streams_operations import SourceControlSyncJobStreamsOperations -from ._job_operations import JobOperations -from ._job_stream_operations import JobStreamOperations from ._automation_account_operations import AutomationAccountOperations from ._statistics_operations import StatisticsOperations from ._usages_operations import UsagesOperations @@ -33,8 +27,6 @@ from ._connection_operations import ConnectionOperations from ._connection_type_operations import ConnectionTypeOperations from ._credential_operations import CredentialOperations -from ._dsc_configuration_operations import DscConfigurationOperations -from ._software_update_configurations_operations import SoftwareUpdateConfigurationsOperations from ._hybrid_runbook_worker_group_operations import HybridRunbookWorkerGroupOperations from ._job_schedule_operations import JobScheduleOperations from ._linked_workspace_operations import LinkedWorkspaceOperations @@ -42,32 +34,41 @@ from ._module_operations import ModuleOperations from ._object_data_types_operations import ObjectDataTypesOperations from ._fields_operations import FieldsOperations -from ._operations import Operations from ._schedule_operations import ScheduleOperations from ._variable_operations import VariableOperations from ._watcher_operations import WatcherOperations +from ._dsc_configuration_operations import DscConfigurationOperations +from ._job_operations import JobOperations +from ._job_stream_operations import JobStreamOperations +from ._operations import Operations +from ._automation_client_operations import AutomationClientOperationsMixin +from ._software_update_configurations_operations import SoftwareUpdateConfigurationsOperations +from ._software_update_configuration_runs_operations import SoftwareUpdateConfigurationRunsOperations +from ._software_update_configuration_machine_runs_operations import SoftwareUpdateConfigurationMachineRunsOperations +from ._runbook_draft_operations import RunbookDraftOperations +from ._runbook_operations import RunbookOperations +from ._test_job_streams_operations import TestJobStreamsOperations +from ._test_job_operations import TestJobOperations from ._webhook_operations import WebhookOperations +from ._hybrid_runbook_workers_operations import HybridRunbookWorkersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'RunbookDraftOperations', - 'RunbookOperations', - 'TestJobStreamsOperations', - 'TestJobOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', 'Python2PackageOperations', 'AgentRegistrationInformationOperations', 'DscNodeOperations', 'NodeReportsOperations', + 'DscNodeConfigurationOperations', 'DscCompilationJobOperations', 'DscCompilationJobStreamOperations', - 'DscNodeConfigurationOperations', 'NodeCountInformationOperations', - 'SoftwareUpdateConfigurationRunsOperations', - 'SoftwareUpdateConfigurationMachineRunsOperations', 'SourceControlOperations', 'SourceControlSyncJobOperations', 'SourceControlSyncJobStreamsOperations', - 'JobOperations', - 'JobStreamOperations', 'AutomationAccountOperations', 'StatisticsOperations', 'UsagesOperations', @@ -76,8 +77,6 @@ 'ConnectionOperations', 'ConnectionTypeOperations', 'CredentialOperations', - 'DscConfigurationOperations', - 'SoftwareUpdateConfigurationsOperations', 'HybridRunbookWorkerGroupOperations', 'JobScheduleOperations', 'LinkedWorkspaceOperations', @@ -85,9 +84,23 @@ 'ModuleOperations', 'ObjectDataTypesOperations', 'FieldsOperations', - 'Operations', 'ScheduleOperations', 'VariableOperations', 'WatcherOperations', + 'DscConfigurationOperations', + 'JobOperations', + 'JobStreamOperations', + 'Operations', + 'AutomationClientOperationsMixin', + 'SoftwareUpdateConfigurationsOperations', + 'SoftwareUpdateConfigurationRunsOperations', + 'SoftwareUpdateConfigurationMachineRunsOperations', + 'RunbookDraftOperations', + 'RunbookOperations', + 'TestJobStreamsOperations', + 'TestJobOperations', 'WebhookOperations', + 'HybridRunbookWorkersOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py index f3fd231d0257..a5177e26ee70 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._activity_operations import build_get_request, build_list_by_module_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActivityOperations: - """ActivityOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`activity` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, module_name: str, activity_name: str, - **kwargs - ) -> "_models.Activity": + **kwargs: Any + ) -> _models.Activity: """Retrieve the activity in the module identified by module name and activity name. :param resource_group_name: Name of an Azure Resource group. @@ -59,45 +64,50 @@ async def get( :type module_name: str :param activity_name: The name of activity. :type activity_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Activity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'activityName': self._serialize.url("activity_name", activity_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Activity] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + activity_name=activity_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Activity', pipeline_response) @@ -106,15 +116,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}"} # type: ignore + + + @distributed_trace def list_by_module( self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs - ) -> AsyncIterable["_models.ActivityListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ActivityListResult]: """Retrieve a list of activities in the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -123,47 +136,60 @@ def list_by_module( :type automation_account_name: str :param module_name: The name of module. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActivityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ActivityListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_module.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_module.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ActivityListResult', pipeline_response) + deserialized = self._deserialize("ActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,17 +198,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_module.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities'} # type: ignore + list_by_module.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py index c0f984e15215..cd72eb05200f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._agent_registration_information_operations import build_get_request, build_regenerate_key_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AgentRegistrationInformationOperations: - """AgentRegistrationInformationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`agent_registration_information` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> "_models.AgentRegistration": + **kwargs: Any + ) -> _models.AgentRegistration: """Retrieve the automation agent registration information. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentRegistration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AgentRegistration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AgentRegistration', pipeline_response) @@ -97,15 +106,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation"} # type: ignore + + + @distributed_trace_async async def regenerate_key( self, resource_group_name: str, automation_account_name: str, - parameters: "_models.AgentRegistrationRegenerateKeyParameter", - **kwargs - ) -> "_models.AgentRegistration": + parameters: _models.AgentRegistrationRegenerateKeyParameter, + **kwargs: Any + ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. :param resource_group_name: Name of an Azure Resource group. @@ -114,48 +126,52 @@ async def regenerate_key( :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentRegistration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AgentRegistration] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') + + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AgentRegistration', pipeline_response) @@ -164,4 +180,6 @@ async def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey'} # type: ignore + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py index c46bc8efda84..9538380e9e9f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._automation_account_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AutomationAccountOperations: - """AutomationAccountOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`automation_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, - parameters: "_models.AutomationAccountUpdateParameters", - **kwargs - ) -> "_models.AutomationAccount": + parameters: _models.AutomationAccountUpdateParameters, + **kwargs: Any + ) -> _models.AutomationAccount: """Update an automation account. :param resource_group_name: Name of an Azure Resource group. @@ -56,48 +61,52 @@ async def update( :type automation_account_name: str :param parameters: Parameters supplied to the update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + _json = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -106,15 +115,18 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, - parameters: "_models.AutomationAccountCreateOrUpdateParameters", - **kwargs - ) -> "_models.AutomationAccount": + parameters: _models.AutomationAccountCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.AutomationAccount: """Create or update automation account. :param resource_group_name: Name of an Azure Resource group. @@ -123,48 +135,52 @@ async def create_or_update( :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + _json = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -177,13 +193,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete an automation account. @@ -191,99 +210,111 @@ async def delete( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> "_models.AutomationAccount": + **kwargs: Any + ) -> _models.AutomationAccount: """Get information about an Automation Account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -292,56 +323,71 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AutomationAccountListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.AutomationAccountListResult]: """Retrieve a list of accounts within a given resource group. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AutomationAccountListResult', pipeline_response) + deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,67 +396,84 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts"} # type: ignore + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["_models.AutomationAccountListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.AutomationAccountListResult]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AutomationAccountListResult', pipeline_response) + deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -419,17 +482,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py new file mode 100644 index 000000000000..8f1f58997321 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py @@ -0,0 +1,100 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._automation_client_operations import build_convert_graph_runbook_content_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AutomationClientOperationsMixin(MixinABC): + + @distributed_trace_async + async def convert_graph_runbook_content( + self, + resource_group_name: str, + automation_account_name: str, + parameters: _models.GraphicalRunbookContent, + **kwargs: Any + ) -> _models.GraphicalRunbookContent: + """Post operation to serialize or deserialize GraphRunbookContent. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param parameters: Input data describing the graphical runbook. + :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GraphicalRunbookContent, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphicalRunbookContent] + + _json = self._serialize.body(parameters, 'GraphicalRunbookContent') + + request = build_convert_graph_runbook_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.convert_graph_runbook_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GraphicalRunbookContent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + convert_graph_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py index 9550ca4ad5a9..6d78b4cef7aa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificate_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CertificateOperations: - """CertificateOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, certificate_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the certificate. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, certificate_name: str, - **kwargs - ) -> "_models.Certificate": + **kwargs: Any + ) -> _models.Certificate: """Retrieve the certificate identified by certificate name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Certificate', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: "_models.CertificateCreateOrUpdateParameters", - **kwargs - ) -> "_models.Certificate": + parameters: _models.CertificateCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Certificate: """Create a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,16 +261,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, certificate_name: str, - parameters: "_models.CertificateUpdateParameters", - **kwargs - ) -> "_models.Certificate": + parameters: _models.CertificateUpdateParameters, + **kwargs: Any + ) -> _models.Certificate: """Update a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -257,49 +284,53 @@ async def update( :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Certificate', pipeline_response) @@ -308,60 +339,76 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.CertificateListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.CertificateListResult]: """Retrieve a list of certificates. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CertificateListResult] + :return: An iterator like instance of either CertificateListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CertificateListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CertificateListResult', pipeline_response) + deserialized = self._deserialize("CertificateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,17 +417,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py index cfaacdf48919..d68cac2b2094 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._connection_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ConnectionOperations: - """ConnectionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`connection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, connection_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, connection_name: str, - **kwargs - ) -> "_models.Connection": + **kwargs: Any + ) -> _models.Connection: """Retrieve the connection identified by connection name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Connection', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: "_models.ConnectionCreateOrUpdateParameters", - **kwargs - ) -> "_models.Connection": + parameters: _models.ConnectionCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Connection: """Create or update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + _json = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,16 +261,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, connection_name: str, - parameters: "_models.ConnectionUpdateParameters", - **kwargs - ) -> "_models.Connection": + parameters: _models.ConnectionUpdateParameters, + **kwargs: Any + ) -> _models.Connection: """Update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -257,49 +284,53 @@ async def update( :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Connection', pipeline_response) @@ -308,60 +339,76 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.ConnectionListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ConnectionListResult]: """Retrieve a list of connections. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionListResult] + :return: An iterator like instance of either ConnectionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConnectionListResult', pipeline_response) + deserialized = self._deserialize("ConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,17 +417,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py index 921ca73acdfd..b8524a869b54 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._connection_type_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ConnectionTypeOperations: - """ConnectionTypeOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`connection_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection type. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - **kwargs - ) -> "_models.ConnectionType": + **kwargs: Any + ) -> _models.ConnectionType: """Retrieve the connection type identified by connection type name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionType"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionType] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConnectionType', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - parameters: "_models.ConnectionTypeCreateOrUpdateParameters", - **kwargs - ) -> "_models.ConnectionType": + parameters: _models.ConnectionTypeCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.ConnectionType: """Create a connection type. :param resource_group_name: Name of an Azure Resource group. @@ -183,49 +203,53 @@ async def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionType"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionType] + + _json = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConnectionType', pipeline_response) @@ -234,60 +258,76 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.ConnectionTypeListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ConnectionTypeListResult]: """Retrieve a list of connection types. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionTypeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] + :return: An iterator like instance of either ConnectionTypeListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionTypeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionTypeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConnectionTypeListResult', pipeline_response) + deserialized = self._deserialize("ConnectionTypeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -296,17 +336,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py index b70ff90697ff..f27e9a1d29ed 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._credential_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CredentialOperations: - """CredentialOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`credential` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, credential_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the credential. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, credential_name: str, - **kwargs - ) -> "_models.Credential": + **kwargs: Any + ) -> _models.Credential: """Retrieve the credential identified by credential name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Credential', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: "_models.CredentialCreateOrUpdateParameters", - **kwargs - ) -> "_models.Credential": + parameters: _models.CredentialCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Credential: """Create a credential. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + _json = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,16 +261,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, credential_name: str, - parameters: "_models.CredentialUpdateParameters", - **kwargs - ) -> "_models.Credential": + parameters: _models.CredentialUpdateParameters, + **kwargs: Any + ) -> _models.Credential: """Update a credential. :param resource_group_name: Name of an Azure Resource group. @@ -257,49 +284,53 @@ async def update( :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Credential', pipeline_response) @@ -308,60 +339,76 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.CredentialListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.CredentialListResult]: """Retrieve a list of credentials. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CredentialListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CredentialListResult] + :return: An iterator like instance of either CredentialListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CredentialListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CredentialListResult', pipeline_response) + deserialized = self._deserialize("CredentialListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,7 +417,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,7 +430,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py index bd5b087ef960..189cba2eedd2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dsc_compilation_job_operations import build_create_request_initial, build_get_request, build_get_stream_request, build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DscCompilationJobOperations: - """DscCompilationJobOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`dsc_compilation_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: "_models.DscCompilationJobCreateParameters", - **kwargs - ) -> "_models.DscCompilationJob": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] + parameters: _models.DscCompilationJobCreateParameters, + **kwargs: Any + ) -> _models.DscCompilationJob: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] + + _json = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + compilation_job_name=compilation_job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('DscCompilationJob', pipeline_response) @@ -97,16 +101,19 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace_async async def begin_create( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, - parameters: "_models.DscCompilationJobCreateParameters", - **kwargs - ) -> AsyncLROPoller["_models.DscCompilationJob"]: + parameters: _models.DscCompilationJobCreateParameters, + **kwargs: Any + ) -> AsyncLROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. :param resource_group_name: Name of an Azure Resource group. @@ -117,52 +124,64 @@ async def begin_create( :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DscCompilationJob or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DscCompilationJob or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscCompilationJob] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DscCompilationJob', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -171,17 +190,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, - **kwargs - ) -> "_models.DscCompilationJob": + **kwargs: Any + ) -> _models.DscCompilationJob: """Retrieve the Dsc configuration compilation job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -190,44 +210,49 @@ async def get( :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. :type compilation_job_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + compilation_job_name=compilation_job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscCompilationJob', pipeline_response) @@ -236,65 +261,81 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DscCompilationJobListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.DscCompilationJobListResult]: """Retrieve a list of dsc compilation jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscCompilationJobListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] + :return: An iterator like instance of either DscCompilationJobListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJobListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJobListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DscCompilationJobListResult', pipeline_response) + deserialized = self._deserialize("DscCompilationJobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -303,29 +344,35 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs"} # type: ignore + @distributed_trace_async async def get_stream( self, resource_group_name: str, automation_account_name: str, job_id: str, job_stream_id: str, - **kwargs - ) -> "_models.JobStream": + **kwargs: Any + ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. :param resource_group_name: Name of an Azure Resource group. @@ -336,45 +383,50 @@ async def get_stream( :type job_id: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_stream.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] + + + request = build_get_stream_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_id=job_id, + job_stream_id=job_stream_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stream.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -383,4 +435,6 @@ async def get_stream( return cls(pipeline_response, deserialized, {}) return deserialized - get_stream.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}'} # type: ignore + + get_stream.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py index b5ceebb497b1..c4e8bd85ce34 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dsc_compilation_job_stream_operations import build_list_by_job_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DscCompilationJobStreamOperations: - """DscCompilationJobStreamOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`dsc_compilation_job_stream` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list_by_job( self, resource_group_name: str, automation_account_name: str, job_id: str, - **kwargs - ) -> "_models.JobStreamListResult": + **kwargs: Any + ) -> _models.JobStreamListResult: """Retrieve all the job streams for the compilation Job. :param resource_group_name: Name of an Azure Resource group. @@ -55,44 +59,49 @@ async def list_by_job( :type automation_account_name: str :param job_id: The job id. :type job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStreamListResult', pipeline_response) @@ -101,4 +110,6 @@ async def list_by_job( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams'} # type: ignore + + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py index fa2cc5f3e6a9..c2204638d83e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dsc_configuration_operations import build_create_or_update_request, build_delete_request, build_get_content_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DscConfigurationOperations: - """DscConfigurationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`dsc_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc configuration identified by configuration name. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs - ) -> "_models.DscConfiguration": + **kwargs: Any + ) -> _models.DscConfiguration: """Retrieve the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscConfiguration', pipeline_response) @@ -162,16 +179,21 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - parameters: Union[str, "_models.DscConfigurationCreateOrUpdateParameters"], - **kwargs - ) -> "_models.DscConfiguration": + parameters: Union[str, _models.DscConfigurationCreateOrUpdateParameters], + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -182,60 +204,67 @@ async def create_or_update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Known values are: "text/plain; + charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/plain; charset=utf-8") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['text/plain']: - body_content = self._serialize.body(parameters, 'str') - body_content_kwargs['content'] = body_content - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - body_content = self._serialize.body(parameters, 'DscConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + _json = None + _content = None + content_type = content_type or "" + if content_type.split(";")[0] in ['application/json']: + _json = parameters + elif content_type.split(";")[0] in ['text/plain']: + _content = parameters else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['text/plain; charset=utf-8', 'application/json']".format(header_parameters['Content-Type']) + "['text/plain; charset=utf-8', 'application/json']".format(content_type) ) - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -248,16 +277,21 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - parameters: Optional[Union[str, "_models.DscConfigurationUpdateParameters"]] = None, - **kwargs - ) -> "_models.DscConfiguration": + parameters: Optional[Union[str, _models.DscConfigurationUpdateParameters]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -266,65 +300,69 @@ async def update( :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. :type configuration_name: str - :param parameters: The create or update parameters for configuration. + :param parameters: The create or update parameters for configuration. Default value is None. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Known values are: "text/plain; + charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/plain; charset=utf-8") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['text/plain']: - body_content = self._serialize.body(parameters, 'str') - body_content_kwargs['content'] = body_content - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - if parameters is not None: - body_content = self._serialize.body(parameters, 'DscConfigurationUpdateParameters') - else: - body_content = None - body_content_kwargs['content'] = body_content + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + _json = None + _content = None + content_type = content_type or "" + if content_type.split(";")[0] in ['application/json']: + _json = parameters + elif content_type.split(";")[0] in ['text/plain']: + _content = parameters else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['text/plain; charset=utf-8', 'application/json']".format(header_parameters['Content-Type']) + "['text/plain; charset=utf-8', 'application/json']".format(content_type) ) - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscConfiguration', pipeline_response) @@ -333,14 +371,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> str: """Retrieve the configuration script identified by configuration name. @@ -350,39 +391,44 @@ async def get_content( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] + + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,8 +441,11 @@ async def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -405,70 +454,83 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DscConfigurationListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.DscConfigurationListResult]: """Retrieve a list of configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] + :return: An iterator like instance of either DscConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfigurationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DscConfigurationListResult', pipeline_response) + deserialized = self._deserialize("DscConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -477,17 +539,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py index 1b76e60c6110..bf2f05b22974 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dsc_node_configuration_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DscNodeConfigurationOperations: - """DscNodeConfigurationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`dsc_node_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the Dsc node configurations by node configuration. @@ -58,58 +63,65 @@ async def delete( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - **kwargs - ) -> "_models.DscNodeConfiguration": + **kwargs: Any + ) -> _models.DscNodeConfiguration: """Retrieve the Dsc node configurations by node configuration. :param resource_group_name: Name of an Azure Resource group. @@ -118,44 +130,49 @@ async def get( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNodeConfiguration', pipeline_response) @@ -164,55 +181,57 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: "_models.DscNodeConfigurationCreateOrUpdateParameters", - **kwargs - ) -> Optional["_models.DscNodeConfiguration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DscNodeConfiguration"]] + parameters: _models.DscNodeConfigurationCreateOrUpdateParameters, + **kwargs: Any + ) -> Optional[_models.DscNodeConfiguration]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DscNodeConfiguration]] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 201: @@ -222,16 +241,19 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - parameters: "_models.DscNodeConfigurationCreateOrUpdateParameters", - **kwargs - ) -> AsyncLROPoller["_models.DscNodeConfiguration"]: + parameters: _models.DscNodeConfigurationCreateOrUpdateParameters, + **kwargs: Any + ) -> AsyncLROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -242,52 +264,64 @@ async def begin_create_or_update( :type node_configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DscNodeConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfiguration] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DscNodeConfiguration', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -296,10 +330,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -308,70 +343,83 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DscNodeConfigurationListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.DscNodeConfigurationListResult]: """Retrieve a list of dsc node configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] + :return: An iterator like instance of either DscNodeConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfigurationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeConfigurationListResult', pipeline_response) + deserialized = self._deserialize("DscNodeConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -380,17 +428,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py index c57d748bf2ee..e9c00950ccb5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._dsc_node_operations import build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DscNodeOperations: - """DscNodeOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`dsc_node` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, node_id: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc node identified by node id. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, - **kwargs - ) -> "_models.DscNode": + **kwargs: Any + ) -> _models.DscNode: """Retrieve the dsc node identified by node id. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNode"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNode] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, node_id: str, - dsc_node_update_parameters: "_models.DscNodeUpdateParameters", - **kwargs - ) -> "_models.DscNode": + dsc_node_update_parameters: _models.DscNodeUpdateParameters, + **kwargs: Any + ) -> _models.DscNode: """Update the dsc node. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def update( :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNode"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNode] + + _json = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -233,8 +257,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -243,70 +270,82 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DscNodeListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.DscNodeListResult]: """Retrieve a list of dsc nodes. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeListResult', pipeline_response) + deserialized = self._deserialize("DscNodeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -315,17 +354,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py index 46dad5908054..5d0643cc92b1 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._fields_operations import build_list_by_type_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FieldsOperations: - """FieldsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`fields` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_type( self, resource_group_name: str, automation_account_name: str, module_name: str, type_name: str, - **kwargs - ) -> AsyncIterable["_models.TypeFieldListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -59,48 +63,62 @@ def list_by_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +127,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py index 26bbf388d578..cc8d53f6df19 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._hybrid_runbook_worker_group_operations import build_create_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class HybridRunbookWorkerGroupOperations: - """HybridRunbookWorkerGroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`hybrid_runbook_worker_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a hybrid runbook worker group. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - **kwargs - ) -> "_models.HybridRunbookWorkerGroup": + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: """Retrieve a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,129 @@ async def get( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_group_creation_parameters: _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: + """Create a hybrid runbook worker group. - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for + hybrid runbook worker group. + :type hybrid_runbook_worker_group_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorkerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + _json = self._serialize.body(hybrid_runbook_worker_group_creation_parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -162,16 +259,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - parameters: "_models.HybridRunbookWorkerGroupUpdateParameters", - **kwargs - ) -> "_models.HybridRunbookWorkerGroup": + parameters: _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -181,50 +281,55 @@ async def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str :param parameters: The hybrid runbook worker group. - :type parameters: ~azure.mgmt.automation.models.HybridRunbookWorkerGroupUpdateParameters + :type parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridRunbookWorkerGroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + _json = self._serialize.body(parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -233,65 +338,81 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.HybridRunbookWorkerGroupsListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.HybridRunbookWorkerGroupsListResult]: """Retrieve a list of hybrid runbook worker groups. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] + :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroupsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroupsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HybridRunbookWorkerGroupsListResult', pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -300,17 +421,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py new file mode 100644 index 000000000000..f909014d5411 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,459 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hybrid_runbook_workers_operations import build_create_request, build_delete_request, build_get_request, build_list_by_hybrid_runbook_worker_group_request, build_move_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class HybridRunbookWorkersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`hybrid_runbook_workers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> None: + """Delete a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> _models.HybridRunbookWorker: + """Retrieve a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorker] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_creation_parameters: _models.HybridRunbookWorkerCreateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorker: + """Create a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid + runbook worker. + :type hybrid_runbook_worker_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorker] + + _json = self._serialize.body(hybrid_runbook_worker_creation_parameters, 'HybridRunbookWorkerCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def move( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_move_parameters: _models.HybridRunbookWorkerMoveParameters, + **kwargs: Any + ) -> None: + """Move a hybrid worker to a different group. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. + :type hybrid_runbook_worker_move_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(hybrid_runbook_worker_move_parameters, 'HybridRunbookWorkerMoveParameters') + + request = build_move_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + move.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move"} # type: ignore + + + @distributed_trace + def list_by_hybrid_runbook_worker_group( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.HybridRunbookWorkersListResult]: + """Retrieve a list of hybrid runbook workers. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridRunbookWorkersListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkersListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkersListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HybridRunbookWorkersListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_hybrid_runbook_worker_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py index e0d98349d7c7..34cc6818aa98 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_operations import build_create_request, build_get_output_request, build_get_request, build_get_runbook_content_request, build_list_by_automation_account_request, build_resume_request, build_stop_request, build_suspend_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class JobOperations: - """JobOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_output( self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> str: """Retrieve the job output identified by job name. @@ -57,43 +62,47 @@ async def get_output( :type automation_account_name: str :param job_name: The name of the job to be created. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/plain" - - # Construct URL - url = self.get_output.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,15 +115,18 @@ async def get_output( return cls(pipeline_response, deserialized, {}) return deserialized - get_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output'} # type: ignore + get_output.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output"} # type: ignore + + + @distributed_trace_async async def get_runbook_content( self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> str: """Retrieve the runbook content of the job identified by job name. @@ -124,43 +136,47 @@ async def get_runbook_content( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_runbook_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_runbook_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,15 +189,18 @@ async def get_runbook_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_runbook_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent'} # type: ignore - async def suspend( + get_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent"} # type: ignore + + + @distributed_trace_async + async def suspend( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Suspend the job identified by job name. @@ -191,62 +210,68 @@ async def suspend( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.suspend.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend"} # type: ignore + - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Stop the job identified by jobName. @@ -256,63 +281,69 @@ async def stop( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.Job": + **kwargs: Any + ) -> _models.Job: """Retrieve the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -321,48 +352,52 @@ async def get( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -371,17 +406,20 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, job_name: str, - parameters: "_models.JobCreateParameters", + parameters: _models.JobCreateParameters, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.Job": + **kwargs: Any + ) -> _models.Job: """Create a job of the runbook. :param resource_group_name: Name of an Azure Resource group. @@ -392,53 +430,56 @@ async def create( :type job_name: str :param parameters: The parameters supplied to the create job operation. :type parameters: ~azure.mgmt.automation.models.JobCreateParameters - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + + _json = self._serialize.body(parameters, 'JobCreateParameters') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -447,70 +488,84 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, client_request_id: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.JobListResultV2"]: + **kwargs: Any + ) -> AsyncIterable[_models.JobListResultV2]: """Retrieve a list of jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobListResultV2 or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobListResultV2] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobListResultV2"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobListResultV2] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobListResultV2', pipeline_response) + deserialized = self._deserialize("JobListResultV2", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -519,28 +574,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs"} # type: ignore - async def resume( + @distributed_trace_async + async def resume( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Resume the job identified by jobName. @@ -550,51 +611,56 @@ async def resume( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.resume.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_resume_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.resume.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py index fe0c83b3f10e..b003b08a9002 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_schedule_operations import build_create_request, build_delete_request, build_get_request, build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class JobScheduleOperations: - """JobScheduleOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`job_schedule` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, - **kwargs + **kwargs: Any ) -> None: """Delete the job schedule identified by job schedule name. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, - **kwargs - ) -> "_models.JobSchedule": + **kwargs: Any + ) -> _models.JobSchedule: """Retrieve the job schedule identified by job schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobSchedule] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, - parameters: "_models.JobScheduleCreateParameters", - **kwargs - ) -> "_models.JobSchedule": + parameters: _models.JobScheduleCreateParameters, + **kwargs: Any + ) -> _models.JobSchedule: """Create a job schedule. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create( :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobScheduleCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobSchedule] + + _json = self._serialize.body(parameters, 'JobScheduleCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -233,65 +257,81 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.JobScheduleListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.JobScheduleListResult]: """Retrieve a list of job schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] + :return: An iterator like instance of either JobScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobScheduleListResult', pipeline_response) + deserialized = self._deserialize("JobScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -300,17 +340,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py index 7a79fe7c3750..3fc7d7371428 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,46 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._job_stream_operations import build_get_request, build_list_by_job_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class JobStreamOperations: - """JobStreamOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`job_stream` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -48,8 +53,8 @@ async def get( job_name: str, job_stream_id: str, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.JobStream": + **kwargs: Any + ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. :param resource_group_name: Name of an Azure Resource group. @@ -60,49 +65,53 @@ async def get( :type job_name: str :param job_stream_id: The job stream id. :type job_stream_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + job_stream_id=job_stream_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -111,8 +120,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -120,8 +132,8 @@ def list_by_job( job_name: str, filter: Optional[str] = None, client_request_id: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.JobStreamListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.JobStreamListResult]: """Retrieve a list of jobs streams identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -130,55 +142,68 @@ def list_by_job( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobStreamListResult', pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -187,17 +212,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams'} # type: ignore + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py index 580c72ba99ef..dd8b6399aa63 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._keys_operations import build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class KeysOperations: - """KeysOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> "_models.KeyListResult": + **kwargs: Any + ) -> _models.KeyListResult: """Retrieve the automation keys for an account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.KeyListResult] + + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('KeyListResult', pipeline_response) @@ -97,4 +106,6 @@ async def list_by_automation_account( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys'} # type: ignore + + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py index d7b7686e96ce..b9c8bb391494 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._linked_workspace_operations import build_get_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LinkedWorkspaceOperations: - """LinkedWorkspaceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`linked_workspace` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> "_models.LinkedWorkspace": + **kwargs: Any + ) -> _models.LinkedWorkspace: """Retrieve the linked workspace for the account id. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedWorkspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedWorkspace] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LinkedWorkspace', pipeline_response) @@ -97,4 +106,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py index 13311f118366..bad8f9db3f4e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._module_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ModuleOperations: - """ModuleOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`module` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the module by name. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs - ) -> "_models.Module": + **kwargs: Any + ) -> _models.Module: """Retrieve the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: "_models.ModuleCreateOrUpdateParameters", - **kwargs - ) -> "_models.Module": + parameters: _models.ModuleCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Create or Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create_or_update( :type module_name: str :param parameters: The create or update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,16 +261,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, module_name: str, - parameters: "_models.ModuleUpdateParameters", - **kwargs - ) -> "_models.Module": + parameters: _models.ModuleUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -257,49 +284,53 @@ async def update( :type module_name: str :param parameters: The update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -308,60 +339,74 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.ModuleListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ModuleListResult]: """Retrieve a list of modules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ModuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ModuleListResult', pipeline_response) + deserialized = self._deserialize("ModuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,17 +415,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py index aec38db50025..da42a224df54 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._node_count_information_operations import build_get_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NodeCountInformationOperations: - """NodeCountInformationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`node_count_information` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, count_type: Union[str, "_models.CountType"], - **kwargs - ) -> "_models.NodeCounts": + **kwargs: Any + ) -> _models.NodeCounts: """Retrieve counts for Dsc Nodes. :param resource_group_name: Name of an Azure Resource group. @@ -55,44 +59,49 @@ async def get( :type automation_account_name: str :param count_type: The type of counts to retrieve. :type count_type: str or ~azure.mgmt.automation.models.CountType + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeCounts"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'countType': self._serialize.url("count_type", count_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NodeCounts] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + count_type=count_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NodeCounts', pipeline_response) @@ -101,4 +110,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py index 48789a3db04d..6077045b23e9 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._node_reports_operations import build_get_content_request, build_get_request, build_list_by_node_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NodeReportsOperations: - """NodeReportsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`node_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_node( self, resource_group_name: str, automation_account_name: str, node_id: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DscNodeReportListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.DscNodeReportListResult]: """Retrieve the Dsc node report list by node id. :param resource_group_name: Name of an Azure Resource group. @@ -57,51 +62,65 @@ def list_by_node( :type automation_account_name: str :param node_id: The parameters supplied to the list operation. :type node_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeReportListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] + :return: An iterator like instance of either DscNodeReportListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReportListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeReportListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_node.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_node.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeReportListResult', pipeline_response) + deserialized = self._deserialize("DscNodeReportListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,29 +129,35 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_node.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports'} # type: ignore + list_by_node.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, - **kwargs - ) -> "_models.DscNodeReport": + **kwargs: Any + ) -> _models.DscNodeReport: """Retrieve the Dsc node report data by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -143,45 +168,50 @@ async def get( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeReport] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + report_id=report_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNodeReport', pipeline_response) @@ -190,16 +220,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}"} # type: ignore + + + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, - **kwargs - ) -> object: + **kwargs: Any + ) -> Any: """Retrieve the Dsc node reports by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -210,45 +243,50 @@ async def get_content( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Any] + + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + report_id=report_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('object', pipeline_response) @@ -257,4 +295,6 @@ async def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py index 35507366f372..1d2820ca017b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._object_data_types_operations import build_list_fields_by_module_and_type_request, build_list_fields_by_type_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectDataTypesOperations: - """ObjectDataTypesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`object_data_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_fields_by_module_and_type( self, resource_group_name: str, automation_account_name: str, module_name: str, type_name: str, - **kwargs - ) -> AsyncIterable["_models.TypeFieldListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -59,48 +63,62 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_module_and_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_module_and_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,28 +127,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_fields_by_module_and_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_module_and_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields"} # type: ignore + @distributed_trace def list_fields_by_type( self, resource_group_name: str, automation_account_name: str, type_name: str, - **kwargs - ) -> AsyncIterable["_models.TypeFieldListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type across all accessible modules. :param resource_group_name: Name of an Azure Resource group. @@ -139,47 +163,60 @@ def list_fields_by_type( :type automation_account_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,17 +225,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_fields_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py index 5646e67f5ae1..e6c42b890f6c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["_models.OperationListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Automation REST API operations. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +105,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Automation/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Automation/operations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..1a9942a74962 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,490 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_automation_account_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_automation_account( + self, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + """List all private endpoint connections on a Automation account. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param parameters: + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..39791692e717 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,138 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_automation_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def automation( + self, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: + """Gets the private link resources that need to be created for Automation account. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.PrivateLinkResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.automation.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + automation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py index b4753198f4b6..eb2ea2a6f512 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._python2_package_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Python2PackageOperations: - """Python2PackageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`python2_package` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def delete( + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, package_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the python 2 package by name. @@ -56,58 +61,65 @@ async def delete( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, package_name: str, - **kwargs - ) -> "_models.Module": + **kwargs: Any + ) -> _models.Module: """Retrieve the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -116,44 +128,49 @@ async def get( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -162,16 +179,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: "_models.PythonPackageCreateParameters", - **kwargs - ) -> "_models.Module": + parameters: _models.PythonPackageCreateParameters, + **kwargs: Any + ) -> _models.Module: """Create or Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -182,49 +202,53 @@ async def create_or_update( :type package_name: str :param parameters: The create or update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'PythonPackageCreateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,16 +261,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, package_name: str, - parameters: "_models.PythonPackageUpdateParameters", - **kwargs - ) -> "_models.Module": + parameters: _models.PythonPackageUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -257,49 +284,53 @@ async def update( :type package_name: str :param parameters: The update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -308,60 +339,74 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.ModuleListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ModuleListResult]: """Retrieve a list of python 2 packages. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ModuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ModuleListResult', pipeline_response) + deserialized = self._deserialize("ModuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,17 +415,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py index 5118a9366302..7ae8c54fa591 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._runbook_draft_operations import build_get_content_request, build_get_request, build_replace_content_request_initial, build_undo_edit_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RunbookDraftOperations: - """RunbookDraftOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`runbook_draft` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> str: + **kwargs: Any + ) -> IO: """Retrieve the content of runbook draft identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -57,52 +61,59 @@ async def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + async def _replace_content_initial( self, @@ -110,65 +121,74 @@ async def _replace_content_initial( automation_account_name: str, runbook_name: str, runbook_content: str, - **kwargs - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] + **kwargs: Any + ) -> Optional[IO]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/powershell") - accept = "application/json" - - # Construct URL - url = self._replace_content_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(runbook_content, 'str') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "text/powershell")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[IO]] + + _content = runbook_content + + request = build_replace_content_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=True, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) + + return deserialized - _replace_content_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + _replace_content_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + + @distributed_trace_async async def begin_replace_content( self, resource_group_name: str, automation_account_name: str, runbook_name: str, runbook_content: str, - **kwargs - ) -> AsyncLROPoller[None]: + **kwargs: Any + ) -> AsyncLROPoller[IO]: """Replaces the runbook draft content. :param resource_group_name: Name of an Azure Resource group. @@ -177,51 +197,65 @@ async def begin_replace_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param runbook_content: The runbook draft content. + :param runbook_content: The runbook draft content. :type runbook_content: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IO or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[IO] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "text/powershell")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[IO] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._replace_content_initial( + raw_result = await self._replace_content_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -230,17 +264,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_replace_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> "_models.RunbookDraft": + **kwargs: Any + ) -> _models.RunbookDraft: """Retrieve the runbook draft identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -249,44 +284,49 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookDraft"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookDraft] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RunbookDraft', pipeline_response) @@ -295,15 +335,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft"} # type: ignore + + + @distributed_trace_async async def undo_edit( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> None: + **kwargs: Any + ) -> _models.RunbookDraftUndoEditResult: """Undo draft edit to last known published state identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -312,47 +355,57 @@ async def undo_edit( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: RunbookDraftUndoEditResult, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.undo_edit.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookDraftUndoEditResult] + + + request = build_undo_edit_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.undo_edit.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize('RunbookDraftUndoEditResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized + + undo_edit.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit"} # type: ignore - undo_edit.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit'} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py index bed2db8ae795..fcfcf3428727 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._runbook_operations import build_create_or_update_request, build_delete_request, build_get_content_request, build_get_request, build_list_by_automation_account_request, build_publish_request_initial, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RunbookOperations: - """RunbookOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`runbook` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - async def _publish_initial( + async def _publish_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self._publish_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_publish_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self._publish_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) - _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + _publish_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + - async def begin_publish( + @distributed_trace_async + async def begin_publish( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Publish runbook draft. @@ -108,48 +116,58 @@ async def begin_publish( :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._publish_initial( + raw_result = await self._publish_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -158,17 +176,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> str: + **kwargs: Any + ) -> IO: """Retrieve the content of runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -177,60 +196,68 @@ async def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> "_models.Runbook": + **kwargs: Any + ) -> _models.Runbook: """Retrieve the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -239,44 +266,49 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Runbook', pipeline_response) @@ -285,16 +317,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: "_models.RunbookCreateOrUpdateParameters", - **kwargs - ) -> "_models.Runbook": + parameters: _models.RunbookCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Runbook: """Create the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -306,49 +341,53 @@ async def create_or_update( :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + _json = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -361,16 +400,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: "_models.RunbookUpdateParameters", - **kwargs - ) -> "_models.Runbook": + parameters: _models.RunbookUpdateParameters, + **kwargs: Any + ) -> _models.Runbook: """Update the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -381,49 +423,53 @@ async def update( :type runbook_name: str :param parameters: The update parameters for runbook. :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + _json = self._serialize.body(parameters, 'RunbookUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Runbook', pipeline_response) @@ -432,14 +478,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the runbook by name. @@ -449,103 +498,122 @@ async def delete( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.RunbookListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.RunbookListResult]: """Retrieve a list of runbooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RunbookListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.RunbookListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.RunbookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RunbookListResult', pipeline_response) + deserialized = self._deserialize("RunbookListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -554,17 +622,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py index a23002841dcb..e0d338c22709 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._schedule_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScheduleOperations: - """ScheduleOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`schedule` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: "_models.ScheduleCreateOrUpdateParameters", - **kwargs - ) -> Optional["_models.Schedule"]: + parameters: _models.ScheduleCreateOrUpdateParameters, + **kwargs: Any + ) -> Optional[_models.Schedule]: """Create a schedule. :param resource_group_name: Name of an Azure Resource group. @@ -59,49 +64,53 @@ async def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Schedule"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Schedule]] + + _json = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -115,16 +124,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, schedule_name: str, - parameters: "_models.ScheduleUpdateParameters", - **kwargs - ) -> "_models.Schedule": + parameters: _models.ScheduleUpdateParameters, + **kwargs: Any + ) -> _models.Schedule: """Update the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -135,49 +147,53 @@ async def update( :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Schedule] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Schedule', pipeline_response) @@ -186,15 +202,18 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, schedule_name: str, - **kwargs - ) -> "_models.Schedule": + **kwargs: Any + ) -> _models.Schedule: """Retrieve the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -203,44 +222,49 @@ async def get( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Schedule] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Schedule', pipeline_response) @@ -249,14 +273,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, schedule_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the schedule identified by schedule name. @@ -266,103 +293,122 @@ async def delete( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.ScheduleListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.ScheduleListResult]: """Retrieve a list of schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ScheduleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ScheduleListResult', pipeline_response) + deserialized = self._deserialize("ScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -371,17 +417,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py index 3ca0dfd2d7d8..c068bf2c255a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._software_update_configuration_machine_runs_operations import build_get_by_id_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SoftwareUpdateConfigurationMachineRunsOperations: - """SoftwareUpdateConfigurationMachineRunsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`software_update_configuration_machine_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_by_id( self, resource_group_name: str, automation_account_name: str, software_update_configuration_machine_run_id: str, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfigurationMachineRun": + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationMachineRun: """Get a single software update configuration machine run by Id. :param resource_group_name: Name of an Azure Resource group. @@ -57,48 +61,52 @@ async def get_by_id( :param software_update_configuration_machine_run_id: The Id of the software update configuration machine run. :type software_update_configuration_machine_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationMachineRun"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationMachineRunId': self._serialize.url("software_update_configuration_machine_run_id", software_update_configuration_machine_run_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationMachineRun] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_machine_run_id=software_update_configuration_machine_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationMachineRun', pipeline_response) @@ -107,8 +115,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}"} # type: ignore + + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -117,69 +128,71 @@ async def list( filter: Optional[str] = None, skip: Optional[str] = None, top: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfigurationMachineRunListResult": + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationMachineRunListResult: """Return list of software update configuration machine runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: number of entries you skip before returning results. + :param skip: number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationMachineRunListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationMachineRunListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationMachineRunListResult', pipeline_response) @@ -188,4 +201,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py index ae3084d09235..c403ab0be327 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._software_update_configuration_runs_operations import build_get_by_id_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SoftwareUpdateConfigurationRunsOperations: - """SoftwareUpdateConfigurationRunsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`software_update_configuration_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_by_id( self, resource_group_name: str, automation_account_name: str, software_update_configuration_run_id: str, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfigurationRun": + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationRun: """Get a single software update configuration Run by Id. :param resource_group_name: Name of an Azure Resource group. @@ -56,48 +60,52 @@ async def get_by_id( :type automation_account_name: str :param software_update_configuration_run_id: The Id of the software update configuration run. :type software_update_configuration_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationRun"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationRunId': self._serialize.url("software_update_configuration_run_id", software_update_configuration_run_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationRun] + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_run_id=software_update_configuration_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationRun', pipeline_response) @@ -106,8 +114,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}"} # type: ignore + + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -116,69 +127,71 @@ async def list( filter: Optional[str] = None, skip: Optional[str] = None, top: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfigurationRunListResult": + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationRunListResult: """Return list of software update configuration runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: Number of entries you skip before returning results. + :param skip: Number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationRunListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationRunListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationRunListResult', pipeline_response) @@ -187,4 +200,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py index 5ef8f8af42b3..129f7a7afc07 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._software_update_configurations_operations import build_create_request, build_delete_request, build_get_by_name_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SoftwareUpdateConfigurationsOperations: - """SoftwareUpdateConfigurationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`software_update_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, - parameters: "_models.SoftwareUpdateConfiguration", + parameters: _models.SoftwareUpdateConfiguration, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfiguration": + **kwargs: Any + ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. :param resource_group_name: Name of an Azure Resource group. @@ -60,53 +64,56 @@ async def create( :type software_update_configuration_name: str :param parameters: Request body. :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SoftwareUpdateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfiguration] + + _json = self._serialize.body(parameters, 'SoftwareUpdateConfiguration') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,16 +126,19 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace_async async def get_by_name( self, resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, client_request_id: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfiguration": + **kwargs: Any + ) -> _models.SoftwareUpdateConfiguration: """Get a single software update configuration by name. :param resource_group_name: Name of an Azure Resource group. @@ -138,48 +148,52 @@ async def get_by_name( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfiguration] + + + request = build_get_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfiguration', pipeline_response) @@ -188,15 +202,18 @@ async def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore - async def delete( + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """delete a specific software update configuration. @@ -207,114 +224,123 @@ async def delete( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, automation_account_name: str, client_request_id: Optional[str] = None, filter: Optional[str] = None, - **kwargs - ) -> "_models.SoftwareUpdateConfigurationListResult": + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationListResult: """Get all software update configurations for the account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationListResult', pipeline_response) @@ -323,4 +349,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py index c23577932dfe..921fc83997a7 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._source_control_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SourceControlOperations: - """SourceControlOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`source_control` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: "_models.SourceControlCreateOrUpdateParameters", - **kwargs - ) -> "_models.SourceControl": + parameters: _models.SourceControlCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.SourceControl: """Create a source control. :param resource_group_name: Name of an Azure Resource group. @@ -59,49 +64,53 @@ async def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + _json = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,16 +123,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, source_control_name: str, - parameters: "_models.SourceControlUpdateParameters", - **kwargs - ) -> "_models.SourceControl": + parameters: _models.SourceControlUpdateParameters, + **kwargs: Any + ) -> _models.SourceControl: """Update a source control. :param resource_group_name: Name of an Azure Resource group. @@ -134,49 +146,53 @@ async def update( :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControl', pipeline_response) @@ -185,14 +201,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, source_control_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the source control. @@ -202,58 +221,65 @@ async def delete( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, source_control_name: str, - **kwargs - ) -> "_models.SourceControl": + **kwargs: Any + ) -> _models.SourceControl: """Retrieve the source control identified by source control name. :param resource_group_name: Name of an Azure Resource group. @@ -262,44 +288,49 @@ async def get( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControl', pipeline_response) @@ -308,65 +339,81 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.SourceControlListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.SourceControlListResult]: """Retrieve a list of source controls. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlListResult] + :return: An iterator like instance of either SourceControlListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlListResult', pipeline_response) + deserialized = self._deserialize("SourceControlListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -375,17 +422,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py index 43a6647ef3a3..260e30922917 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,51 +6,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._source_control_sync_job_operations import build_create_request, build_get_request, build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SourceControlSyncJobOperations: - """SourceControlSyncJobOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`source_control_sync_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - parameters: "_models.SourceControlSyncJobCreateParameters", - **kwargs - ) -> "_models.SourceControlSyncJob": + parameters: _models.SourceControlSyncJobCreateParameters, + **kwargs: Any + ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. :param resource_group_name: Name of an Azure Resource group. @@ -62,50 +67,54 @@ async def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJob] + + _json = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJob', pipeline_response) @@ -114,16 +123,19 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, source_control_name: str, source_control_sync_job_id: str, - **kwargs - ) -> "_models.SourceControlSyncJobById": + **kwargs: Any + ) -> _models.SourceControlSyncJobById: """Retrieve the source control sync job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -134,45 +146,50 @@ async def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobById"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobById] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJobById', pipeline_response) @@ -181,16 +198,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, source_control_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.SourceControlSyncJobListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.SourceControlSyncJobListResult]: """Retrieve a list of source control sync jobs. :param resource_group_name: Name of an Azure Resource group. @@ -199,51 +219,65 @@ def list_by_automation_account( :type automation_account_name: str :param source_control_name: The source control name. :type source_control_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] + :return: An iterator like instance of either SourceControlSyncJobListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlSyncJobListResult', pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -252,17 +286,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py index ca50b6f067f3..dcb52ca73e4a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,46 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._source_control_sync_job_streams_operations import build_get_request, build_list_by_sync_job_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SourceControlSyncJobStreamsOperations: - """SourceControlSyncJobStreamsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`source_control_sync_job_streams` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_sync_job( self, resource_group_name: str, @@ -48,8 +53,8 @@ def list_by_sync_job( source_control_name: str, source_control_sync_job_id: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.SourceControlSyncJobStreamsListBySyncJob"]: + **kwargs: Any + ) -> AsyncIterable[_models.SourceControlSyncJobStreamsListBySyncJob]: """Retrieve a list of sync job streams identified by sync job id. :param resource_group_name: Name of an Azure Resource group. @@ -60,52 +65,67 @@ def list_by_sync_job( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] + :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamsListBySyncJob"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobStreamsListBySyncJob] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlSyncJobStreamsListBySyncJob', pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobStreamsListBySyncJob", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,21 +134,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_sync_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams'} # type: ignore + list_by_sync_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -136,8 +162,8 @@ async def get( source_control_name: str, source_control_sync_job_id: str, stream_id: str, - **kwargs - ) -> "_models.SourceControlSyncJobStreamById": + **kwargs: Any + ) -> _models.SourceControlSyncJobStreamById: """Retrieve a sync job stream identified by stream id. :param resource_group_name: Name of an Azure Resource group. @@ -150,46 +176,51 @@ async def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. :type stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamById"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'streamId': self._serialize.url("stream_id", stream_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobStreamById] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + stream_id=stream_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJobStreamById', pipeline_response) @@ -198,4 +229,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py index 2a4fe0ae52da..6078ff670dec 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._statistics_operations import build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StatisticsOperations: - """StatisticsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`statistics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.StatisticsListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.StatisticsListResult]: """Retrieve the statistics for the account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StatisticsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.StatisticsListResult] + :return: An iterator like instance of either StatisticsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.StatisticsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StatisticsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StatisticsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StatisticsListResult', pipeline_response) + deserialized = self._deserialize("StatisticsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +123,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py index ea440aad6497..a54dac0cb259 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._test_job_operations import build_create_request, build_get_request, build_resume_request, build_stop_request, build_suspend_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TestJobOperations: - """TestJobOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`test_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - parameters: "_models.TestJobCreateParameters", - **kwargs - ) -> "_models.TestJob": + parameters: _models.TestJobCreateParameters, + **kwargs: Any + ) -> _models.TestJob: """Create a test job of the runbook. :param resource_group_name: Name of an Azure Resource group. @@ -58,49 +62,53 @@ async def create( :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TestJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestJob] + + _json = self._serialize.body(parameters, 'TestJobCreateParameters') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -109,15 +117,18 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> "_models.TestJob": + **kwargs: Any + ) -> _models.TestJob: """Retrieve the test job for the specified runbook. :param resource_group_name: Name of an Azure Resource group. @@ -126,44 +137,49 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestJob] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -172,14 +188,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore - async def resume( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace_async + async def resume( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the test job. @@ -189,57 +208,64 @@ async def resume( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.resume.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_resume_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.resume.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume"} # type: ignore - async def stop( + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Stop the test job. @@ -249,57 +275,64 @@ async def stop( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_stop_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop"} # type: ignore + - async def suspend( + @distributed_trace_async + async def suspend( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Suspend the test job. @@ -309,47 +342,53 @@ async def suspend( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.suspend.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.suspend.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py index 55fb84a09c42..d962901a2912 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._test_job_streams_operations import build_get_request, build_list_by_test_job_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TestJobStreamsOperations: - """TestJobStreamsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`test_job_streams` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, job_stream_id: str, - **kwargs - ) -> "_models.JobStream": + **kwargs: Any + ) -> _models.JobStream: """Retrieve a test job stream of the test job identified by runbook name and stream id. :param resource_group_name: Name of an Azure Resource group. @@ -59,45 +64,50 @@ async def get( :type runbook_name: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + job_stream_id=job_stream_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -106,16 +116,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_test_job( self, resource_group_name: str, automation_account_name: str, runbook_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.JobStreamListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.JobStreamListResult]: """Retrieve a list of test job streams identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -124,51 +137,64 @@ def list_by_test_job( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_test_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobStreamListResult', pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,17 +203,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_test_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams'} # type: ignore + list_by_test_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py index 99ddccc83f14..01797311296a 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_automation_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.UsageListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.UsageListResult]: """Retrieve the usage for the account id. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UsageListResult', pipeline_response) + deserialized = self._deserialize("UsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +116,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py index b2d88278a5d9..b1b7063e99b7 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._variable_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VariableOperations: - """VariableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`variable` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: "_models.VariableCreateOrUpdateParameters", - **kwargs - ) -> "_models.Variable": + parameters: _models.VariableCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Variable: """Create a variable. :param resource_group_name: Name of an Azure Resource group. @@ -59,49 +64,53 @@ async def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + _json = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,16 +123,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, variable_name: str, - parameters: "_models.VariableUpdateParameters", - **kwargs - ) -> "_models.Variable": + parameters: _models.VariableUpdateParameters, + **kwargs: Any + ) -> _models.Variable: """Update a variable. :param resource_group_name: Name of an Azure Resource group. @@ -134,49 +146,53 @@ async def update( :type variable_name: str :param parameters: The parameters supplied to the update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Variable', pipeline_response) @@ -185,14 +201,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, variable_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the variable. @@ -202,58 +221,65 @@ async def delete( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, variable_name: str, - **kwargs - ) -> "_models.Variable": + **kwargs: Any + ) -> _models.Variable: """Retrieve the variable identified by variable name. :param resource_group_name: Name of an Azure Resource group. @@ -262,44 +288,49 @@ async def get( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Variable', pipeline_response) @@ -308,60 +339,75 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs - ) -> AsyncIterable["_models.VariableListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.VariableListResult]: """Retrieve a list of variables. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VariableListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.VariableListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.VariableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VariableListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VariableListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VariableListResult', pipeline_response) + deserialized = self._deserialize("VariableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,17 +416,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py index 84c360c06ddc..bacebd618fe5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._watcher_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_automation_account_request, build_start_request, build_stop_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class WatcherOperations: - """WatcherOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`watcher` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: "_models.Watcher", - **kwargs - ) -> "_models.Watcher": + parameters: _models.Watcher, + **kwargs: Any + ) -> _models.Watcher: """Create the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -59,49 +64,53 @@ async def create_or_update( :type watcher_name: str :param parameters: The create or update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.Watcher + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Watcher') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + _json = self._serialize.body(parameters, 'Watcher') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -114,15 +123,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs - ) -> "_models.Watcher": + **kwargs: Any + ) -> _models.Watcher: """Retrieve the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -131,44 +143,49 @@ async def get( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Watcher', pipeline_response) @@ -177,16 +194,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - parameters: "_models.WatcherUpdateParameters", - **kwargs - ) -> "_models.Watcher": + parameters: _models.WatcherUpdateParameters, + **kwargs: Any + ) -> _models.Watcher: """Update the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -197,49 +217,53 @@ async def update( :type watcher_name: str :param parameters: The update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WatcherUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + _json = self._serialize.body(parameters, 'WatcherUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Watcher', pipeline_response) @@ -248,14 +272,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the watcher by name. @@ -265,57 +292,64 @@ async def delete( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore - async def start( + + @distributed_trace_async + async def start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -325,57 +359,64 @@ async def start( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.start.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_start_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.start.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start"} # type: ignore + - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -385,108 +426,127 @@ async def stop( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.WatcherListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.WatcherListResult]: """Retrieve a list of watchers. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WatcherListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WatcherListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WatcherListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WatcherListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WatcherListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WatcherListResult', pipeline_response) + deserialized = self._deserialize("WatcherListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -495,17 +555,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py index 8c7cfe5208a2..74304573e683 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,51 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._webhook_operations import build_create_or_update_request, build_delete_request, build_generate_uri_request, build_get_request, build_list_by_automation_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class WebhookOperations: - """WebhookOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.aio.AutomationClient`'s + :attr:`webhook` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def generate_uri( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> str: """Generates a Uri for use in creating a webhook. @@ -53,43 +58,48 @@ async def generate_uri( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.generate_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] + + + request = build_generate_uri_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_uri.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('str', pipeline_response) @@ -98,14 +108,17 @@ async def generate_uri( return cls(pipeline_response, deserialized, {}) return deserialized - generate_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri'} # type: ignore - async def delete( + generate_uri.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, webhook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the webhook by name. @@ -115,58 +128,65 @@ async def delete( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, webhook_name: str, - **kwargs - ) -> "_models.Webhook": + **kwargs: Any + ) -> _models.Webhook: """Retrieve the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -175,44 +195,49 @@ async def get( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -221,16 +246,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: "_models.WebhookCreateOrUpdateParameters", - **kwargs - ) -> "_models.Webhook": + parameters: _models.WebhookCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Webhook: """Create the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -241,49 +269,53 @@ async def create_or_update( :type webhook_name: str :param parameters: The create or update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + _json = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -296,16 +328,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, webhook_name: str, - parameters: "_models.WebhookUpdateParameters", - **kwargs - ) -> "_models.Webhook": + parameters: _models.WebhookUpdateParameters, + **kwargs: Any + ) -> _models.Webhook: """Update the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -316,49 +351,53 @@ async def update( :type webhook_name: str :param parameters: The update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + _json = self._serialize.body(parameters, 'WebhookUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -367,65 +406,80 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.WebhookListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.WebhookListResult]: """Retrieve a list of webhooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebhookListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WebhookListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WebhookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WebhookListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WebhookListResult', pipeline_response) + deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -434,17 +488,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py index 39d1b340a56f..72ac4f398457 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py @@ -6,330 +6,187 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Activity - from ._models_py3 import ActivityListResult - from ._models_py3 import ActivityOutputType - from ._models_py3 import ActivityParameter - from ._models_py3 import ActivityParameterSet - from ._models_py3 import ActivityParameterValidationSet - from ._models_py3 import AdvancedSchedule - from ._models_py3 import AdvancedScheduleMonthlyOccurrence - from ._models_py3 import AgentRegistration - from ._models_py3 import AgentRegistrationKeys - from ._models_py3 import AgentRegistrationRegenerateKeyParameter - from ._models_py3 import AutomationAccount - from ._models_py3 import AutomationAccountCreateOrUpdateParameters - from ._models_py3 import AutomationAccountListResult - from ._models_py3 import AutomationAccountUpdateParameters - from ._models_py3 import AzureQueryProperties - from ._models_py3 import Certificate - from ._models_py3 import CertificateCreateOrUpdateParameters - from ._models_py3 import CertificateListResult - from ._models_py3 import CertificateUpdateParameters - from ._models_py3 import Connection - from ._models_py3 import ConnectionCreateOrUpdateParameters - from ._models_py3 import ConnectionListResult - from ._models_py3 import ConnectionType - from ._models_py3 import ConnectionTypeAssociationProperty - from ._models_py3 import ConnectionTypeCreateOrUpdateParameters - from ._models_py3 import ConnectionTypeListResult - from ._models_py3 import ConnectionUpdateParameters - from ._models_py3 import ContentHash - from ._models_py3 import ContentLink - from ._models_py3 import ContentSource - from ._models_py3 import Credential - from ._models_py3 import CredentialCreateOrUpdateParameters - from ._models_py3 import CredentialListResult - from ._models_py3 import CredentialUpdateParameters - from ._models_py3 import DscCompilationJob - from ._models_py3 import DscCompilationJobCreateParameters - from ._models_py3 import DscCompilationJobListResult - from ._models_py3 import DscConfiguration - from ._models_py3 import DscConfigurationAssociationProperty - from ._models_py3 import DscConfigurationCreateOrUpdateParameters - from ._models_py3 import DscConfigurationListResult - from ._models_py3 import DscConfigurationParameter - from ._models_py3 import DscConfigurationUpdateParameters - from ._models_py3 import DscMetaConfiguration - from ._models_py3 import DscNode - from ._models_py3 import DscNodeConfiguration - from ._models_py3 import DscNodeConfigurationCreateOrUpdateParameters - from ._models_py3 import DscNodeConfigurationListResult - from ._models_py3 import DscNodeExtensionHandlerAssociationProperty - from ._models_py3 import DscNodeListResult - from ._models_py3 import DscNodeReport - from ._models_py3 import DscNodeReportListResult - from ._models_py3 import DscNodeUpdateParameters - from ._models_py3 import DscNodeUpdateParametersProperties - from ._models_py3 import DscReportError - from ._models_py3 import DscReportResource - from ._models_py3 import DscReportResourceNavigation - from ._models_py3 import ErrorResponse - from ._models_py3 import FieldDefinition - from ._models_py3 import HybridRunbookWorker - from ._models_py3 import HybridRunbookWorkerGroup - from ._models_py3 import HybridRunbookWorkerGroupUpdateParameters - from ._models_py3 import HybridRunbookWorkerGroupsListResult - from ._models_py3 import Job - from ._models_py3 import JobCollectionItem - from ._models_py3 import JobCreateParameters - from ._models_py3 import JobListResultV2 - from ._models_py3 import JobNavigation - from ._models_py3 import JobSchedule - from ._models_py3 import JobScheduleCreateParameters - from ._models_py3 import JobScheduleListResult - from ._models_py3 import JobStream - from ._models_py3 import JobStreamListResult - from ._models_py3 import Key - from ._models_py3 import KeyListResult - from ._models_py3 import LinkedWorkspace - from ._models_py3 import LinuxProperties - from ._models_py3 import Module - from ._models_py3 import ModuleCreateOrUpdateParameters - from ._models_py3 import ModuleErrorInfo - from ._models_py3 import ModuleListResult - from ._models_py3 import ModuleUpdateParameters - from ._models_py3 import NodeCount - from ._models_py3 import NodeCountProperties - from ._models_py3 import NodeCounts - from ._models_py3 import NonAzureQueryProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import ProxyResource - from ._models_py3 import PythonPackageCreateParameters - from ._models_py3 import PythonPackageUpdateParameters - from ._models_py3 import Resource - from ._models_py3 import RunAsCredentialAssociationProperty - from ._models_py3 import Runbook - from ._models_py3 import RunbookAssociationProperty - from ._models_py3 import RunbookCreateOrUpdateDraftParameters - from ._models_py3 import RunbookCreateOrUpdateDraftProperties - from ._models_py3 import RunbookCreateOrUpdateParameters - from ._models_py3 import RunbookDraft - from ._models_py3 import RunbookDraftUndoEditResult - from ._models_py3 import RunbookListResult - from ._models_py3 import RunbookParameter - from ._models_py3 import RunbookUpdateParameters - from ._models_py3 import SUCScheduleProperties - from ._models_py3 import Schedule - from ._models_py3 import ScheduleAssociationProperty - from ._models_py3 import ScheduleCreateOrUpdateParameters - from ._models_py3 import ScheduleListResult - from ._models_py3 import ScheduleUpdateParameters - from ._models_py3 import Sku - from ._models_py3 import SoftwareUpdateConfiguration - from ._models_py3 import SoftwareUpdateConfigurationCollectionItem - from ._models_py3 import SoftwareUpdateConfigurationListResult - from ._models_py3 import SoftwareUpdateConfigurationMachineRun - from ._models_py3 import SoftwareUpdateConfigurationMachineRunListResult - from ._models_py3 import SoftwareUpdateConfigurationRun - from ._models_py3 import SoftwareUpdateConfigurationRunListResult - from ._models_py3 import SoftwareUpdateConfigurationRunTaskProperties - from ._models_py3 import SoftwareUpdateConfigurationRunTasks - from ._models_py3 import SoftwareUpdateConfigurationTasks - from ._models_py3 import SourceControl - from ._models_py3 import SourceControlCreateOrUpdateParameters - from ._models_py3 import SourceControlListResult - from ._models_py3 import SourceControlSecurityTokenProperties - from ._models_py3 import SourceControlSyncJob - from ._models_py3 import SourceControlSyncJobById - from ._models_py3 import SourceControlSyncJobCreateParameters - from ._models_py3 import SourceControlSyncJobListResult - from ._models_py3 import SourceControlSyncJobStream - from ._models_py3 import SourceControlSyncJobStreamById - from ._models_py3 import SourceControlSyncJobStreamsListBySyncJob - from ._models_py3 import SourceControlUpdateParameters - from ._models_py3 import Statistics - from ._models_py3 import StatisticsListResult - from ._models_py3 import TagSettingsProperties - from ._models_py3 import TargetProperties - from ._models_py3 import TaskProperties - from ._models_py3 import TestJob - from ._models_py3 import TestJobCreateParameters - from ._models_py3 import TrackedResource - from ._models_py3 import TypeField - from ._models_py3 import TypeFieldListResult - from ._models_py3 import UpdateConfiguration - from ._models_py3 import UpdateConfigurationNavigation - from ._models_py3 import Usage - from ._models_py3 import UsageCounterName - from ._models_py3 import UsageListResult - from ._models_py3 import Variable - from ._models_py3 import VariableCreateOrUpdateParameters - from ._models_py3 import VariableListResult - from ._models_py3 import VariableUpdateParameters - from ._models_py3 import Watcher - from ._models_py3 import WatcherListResult - from ._models_py3 import WatcherUpdateParameters - from ._models_py3 import Webhook - from ._models_py3 import WebhookCreateOrUpdateParameters - from ._models_py3 import WebhookListResult - from ._models_py3 import WebhookUpdateParameters - from ._models_py3 import WindowsProperties -except (SyntaxError, ImportError): - from ._models import Activity # type: ignore - from ._models import ActivityListResult # type: ignore - from ._models import ActivityOutputType # type: ignore - from ._models import ActivityParameter # type: ignore - from ._models import ActivityParameterSet # type: ignore - from ._models import ActivityParameterValidationSet # type: ignore - from ._models import AdvancedSchedule # type: ignore - from ._models import AdvancedScheduleMonthlyOccurrence # type: ignore - from ._models import AgentRegistration # type: ignore - from ._models import AgentRegistrationKeys # type: ignore - from ._models import AgentRegistrationRegenerateKeyParameter # type: ignore - from ._models import AutomationAccount # type: ignore - from ._models import AutomationAccountCreateOrUpdateParameters # type: ignore - from ._models import AutomationAccountListResult # type: ignore - from ._models import AutomationAccountUpdateParameters # type: ignore - from ._models import AzureQueryProperties # type: ignore - from ._models import Certificate # type: ignore - from ._models import CertificateCreateOrUpdateParameters # type: ignore - from ._models import CertificateListResult # type: ignore - from ._models import CertificateUpdateParameters # type: ignore - from ._models import Connection # type: ignore - from ._models import ConnectionCreateOrUpdateParameters # type: ignore - from ._models import ConnectionListResult # type: ignore - from ._models import ConnectionType # type: ignore - from ._models import ConnectionTypeAssociationProperty # type: ignore - from ._models import ConnectionTypeCreateOrUpdateParameters # type: ignore - from ._models import ConnectionTypeListResult # type: ignore - from ._models import ConnectionUpdateParameters # type: ignore - from ._models import ContentHash # type: ignore - from ._models import ContentLink # type: ignore - from ._models import ContentSource # type: ignore - from ._models import Credential # type: ignore - from ._models import CredentialCreateOrUpdateParameters # type: ignore - from ._models import CredentialListResult # type: ignore - from ._models import CredentialUpdateParameters # type: ignore - from ._models import DscCompilationJob # type: ignore - from ._models import DscCompilationJobCreateParameters # type: ignore - from ._models import DscCompilationJobListResult # type: ignore - from ._models import DscConfiguration # type: ignore - from ._models import DscConfigurationAssociationProperty # type: ignore - from ._models import DscConfigurationCreateOrUpdateParameters # type: ignore - from ._models import DscConfigurationListResult # type: ignore - from ._models import DscConfigurationParameter # type: ignore - from ._models import DscConfigurationUpdateParameters # type: ignore - from ._models import DscMetaConfiguration # type: ignore - from ._models import DscNode # type: ignore - from ._models import DscNodeConfiguration # type: ignore - from ._models import DscNodeConfigurationCreateOrUpdateParameters # type: ignore - from ._models import DscNodeConfigurationListResult # type: ignore - from ._models import DscNodeExtensionHandlerAssociationProperty # type: ignore - from ._models import DscNodeListResult # type: ignore - from ._models import DscNodeReport # type: ignore - from ._models import DscNodeReportListResult # type: ignore - from ._models import DscNodeUpdateParameters # type: ignore - from ._models import DscNodeUpdateParametersProperties # type: ignore - from ._models import DscReportError # type: ignore - from ._models import DscReportResource # type: ignore - from ._models import DscReportResourceNavigation # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import FieldDefinition # type: ignore - from ._models import HybridRunbookWorker # type: ignore - from ._models import HybridRunbookWorkerGroup # type: ignore - from ._models import HybridRunbookWorkerGroupUpdateParameters # type: ignore - from ._models import HybridRunbookWorkerGroupsListResult # type: ignore - from ._models import Job # type: ignore - from ._models import JobCollectionItem # type: ignore - from ._models import JobCreateParameters # type: ignore - from ._models import JobListResultV2 # type: ignore - from ._models import JobNavigation # type: ignore - from ._models import JobSchedule # type: ignore - from ._models import JobScheduleCreateParameters # type: ignore - from ._models import JobScheduleListResult # type: ignore - from ._models import JobStream # type: ignore - from ._models import JobStreamListResult # type: ignore - from ._models import Key # type: ignore - from ._models import KeyListResult # type: ignore - from ._models import LinkedWorkspace # type: ignore - from ._models import LinuxProperties # type: ignore - from ._models import Module # type: ignore - from ._models import ModuleCreateOrUpdateParameters # type: ignore - from ._models import ModuleErrorInfo # type: ignore - from ._models import ModuleListResult # type: ignore - from ._models import ModuleUpdateParameters # type: ignore - from ._models import NodeCount # type: ignore - from ._models import NodeCountProperties # type: ignore - from ._models import NodeCounts # type: ignore - from ._models import NonAzureQueryProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import PythonPackageCreateParameters # type: ignore - from ._models import PythonPackageUpdateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import RunAsCredentialAssociationProperty # type: ignore - from ._models import Runbook # type: ignore - from ._models import RunbookAssociationProperty # type: ignore - from ._models import RunbookCreateOrUpdateDraftParameters # type: ignore - from ._models import RunbookCreateOrUpdateDraftProperties # type: ignore - from ._models import RunbookCreateOrUpdateParameters # type: ignore - from ._models import RunbookDraft # type: ignore - from ._models import RunbookDraftUndoEditResult # type: ignore - from ._models import RunbookListResult # type: ignore - from ._models import RunbookParameter # type: ignore - from ._models import RunbookUpdateParameters # type: ignore - from ._models import SUCScheduleProperties # type: ignore - from ._models import Schedule # type: ignore - from ._models import ScheduleAssociationProperty # type: ignore - from ._models import ScheduleCreateOrUpdateParameters # type: ignore - from ._models import ScheduleListResult # type: ignore - from ._models import ScheduleUpdateParameters # type: ignore - from ._models import Sku # type: ignore - from ._models import SoftwareUpdateConfiguration # type: ignore - from ._models import SoftwareUpdateConfigurationCollectionItem # type: ignore - from ._models import SoftwareUpdateConfigurationListResult # type: ignore - from ._models import SoftwareUpdateConfigurationMachineRun # type: ignore - from ._models import SoftwareUpdateConfigurationMachineRunListResult # type: ignore - from ._models import SoftwareUpdateConfigurationRun # type: ignore - from ._models import SoftwareUpdateConfigurationRunListResult # type: ignore - from ._models import SoftwareUpdateConfigurationRunTaskProperties # type: ignore - from ._models import SoftwareUpdateConfigurationRunTasks # type: ignore - from ._models import SoftwareUpdateConfigurationTasks # type: ignore - from ._models import SourceControl # type: ignore - from ._models import SourceControlCreateOrUpdateParameters # type: ignore - from ._models import SourceControlListResult # type: ignore - from ._models import SourceControlSecurityTokenProperties # type: ignore - from ._models import SourceControlSyncJob # type: ignore - from ._models import SourceControlSyncJobById # type: ignore - from ._models import SourceControlSyncJobCreateParameters # type: ignore - from ._models import SourceControlSyncJobListResult # type: ignore - from ._models import SourceControlSyncJobStream # type: ignore - from ._models import SourceControlSyncJobStreamById # type: ignore - from ._models import SourceControlSyncJobStreamsListBySyncJob # type: ignore - from ._models import SourceControlUpdateParameters # type: ignore - from ._models import Statistics # type: ignore - from ._models import StatisticsListResult # type: ignore - from ._models import TagSettingsProperties # type: ignore - from ._models import TargetProperties # type: ignore - from ._models import TaskProperties # type: ignore - from ._models import TestJob # type: ignore - from ._models import TestJobCreateParameters # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import TypeField # type: ignore - from ._models import TypeFieldListResult # type: ignore - from ._models import UpdateConfiguration # type: ignore - from ._models import UpdateConfigurationNavigation # type: ignore - from ._models import Usage # type: ignore - from ._models import UsageCounterName # type: ignore - from ._models import UsageListResult # type: ignore - from ._models import Variable # type: ignore - from ._models import VariableCreateOrUpdateParameters # type: ignore - from ._models import VariableListResult # type: ignore - from ._models import VariableUpdateParameters # type: ignore - from ._models import Watcher # type: ignore - from ._models import WatcherListResult # type: ignore - from ._models import WatcherUpdateParameters # type: ignore - from ._models import Webhook # type: ignore - from ._models import WebhookCreateOrUpdateParameters # type: ignore - from ._models import WebhookListResult # type: ignore - from ._models import WebhookUpdateParameters # type: ignore - from ._models import WindowsProperties # type: ignore +from ._models_py3 import Activity +from ._models_py3 import ActivityListResult +from ._models_py3 import ActivityOutputType +from ._models_py3 import ActivityParameter +from ._models_py3 import ActivityParameterSet +from ._models_py3 import ActivityParameterValidationSet +from ._models_py3 import AdvancedSchedule +from ._models_py3 import AdvancedScheduleMonthlyOccurrence +from ._models_py3 import AgentRegistration +from ._models_py3 import AgentRegistrationKeys +from ._models_py3 import AgentRegistrationRegenerateKeyParameter +from ._models_py3 import AutomationAccount +from ._models_py3 import AutomationAccountCreateOrUpdateParameters +from ._models_py3 import AutomationAccountListResult +from ._models_py3 import AutomationAccountUpdateParameters +from ._models_py3 import AzureQueryProperties +from ._models_py3 import Certificate +from ._models_py3 import CertificateCreateOrUpdateParameters +from ._models_py3 import CertificateListResult +from ._models_py3 import CertificateUpdateParameters +from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties +from ._models_py3 import Connection +from ._models_py3 import ConnectionCreateOrUpdateParameters +from ._models_py3 import ConnectionListResult +from ._models_py3 import ConnectionType +from ._models_py3 import ConnectionTypeAssociationProperty +from ._models_py3 import ConnectionTypeCreateOrUpdateParameters +from ._models_py3 import ConnectionTypeListResult +from ._models_py3 import ConnectionUpdateParameters +from ._models_py3 import ContentHash +from ._models_py3 import ContentLink +from ._models_py3 import ContentSource +from ._models_py3 import Credential +from ._models_py3 import CredentialCreateOrUpdateParameters +from ._models_py3 import CredentialListResult +from ._models_py3 import CredentialUpdateParameters +from ._models_py3 import DscCompilationJob +from ._models_py3 import DscCompilationJobCreateParameters +from ._models_py3 import DscCompilationJobListResult +from ._models_py3 import DscConfiguration +from ._models_py3 import DscConfigurationAssociationProperty +from ._models_py3 import DscConfigurationCreateOrUpdateParameters +from ._models_py3 import DscConfigurationListResult +from ._models_py3 import DscConfigurationParameter +from ._models_py3 import DscConfigurationUpdateParameters +from ._models_py3 import DscMetaConfiguration +from ._models_py3 import DscNode +from ._models_py3 import DscNodeConfiguration +from ._models_py3 import DscNodeConfigurationCreateOrUpdateParameters +from ._models_py3 import DscNodeConfigurationListResult +from ._models_py3 import DscNodeExtensionHandlerAssociationProperty +from ._models_py3 import DscNodeListResult +from ._models_py3 import DscNodeReport +from ._models_py3 import DscNodeReportListResult +from ._models_py3 import DscNodeUpdateParameters +from ._models_py3 import DscNodeUpdateParametersProperties +from ._models_py3 import DscReportError +from ._models_py3 import DscReportResource +from ._models_py3 import DscReportResourceNavigation +from ._models_py3 import EncryptionProperties +from ._models_py3 import EncryptionPropertiesIdentity +from ._models_py3 import ErrorResponse +from ._models_py3 import FieldDefinition +from ._models_py3 import GraphicalRunbookContent +from ._models_py3 import HybridRunbookWorker +from ._models_py3 import HybridRunbookWorkerCreateParameters +from ._models_py3 import HybridRunbookWorkerGroup +from ._models_py3 import HybridRunbookWorkerGroupCreateOrUpdateParameters +from ._models_py3 import HybridRunbookWorkerGroupUpdateParameters +from ._models_py3 import HybridRunbookWorkerGroupsListResult +from ._models_py3 import HybridRunbookWorkerLegacy +from ._models_py3 import HybridRunbookWorkerMoveParameters +from ._models_py3 import HybridRunbookWorkersListResult +from ._models_py3 import Identity +from ._models_py3 import Job +from ._models_py3 import JobCollectionItem +from ._models_py3 import JobCreateParameters +from ._models_py3 import JobListResultV2 +from ._models_py3 import JobNavigation +from ._models_py3 import JobSchedule +from ._models_py3 import JobScheduleCreateParameters +from ._models_py3 import JobScheduleListResult +from ._models_py3 import JobStream +from ._models_py3 import JobStreamListResult +from ._models_py3 import Key +from ._models_py3 import KeyListResult +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LinkedWorkspace +from ._models_py3 import LinuxProperties +from ._models_py3 import Module +from ._models_py3 import ModuleCreateOrUpdateParameters +from ._models_py3 import ModuleErrorInfo +from ._models_py3 import ModuleListResult +from ._models_py3 import ModuleUpdateParameters +from ._models_py3 import NodeCount +from ._models_py3 import NodeCountProperties +from ._models_py3 import NodeCounts +from ._models_py3 import NonAzureQueryProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointProperty +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionStateProperty +from ._models_py3 import ProxyResource +from ._models_py3 import PythonPackageCreateParameters +from ._models_py3 import PythonPackageUpdateParameters +from ._models_py3 import RawGraphicalRunbookContent +from ._models_py3 import Resource +from ._models_py3 import RunAsCredentialAssociationProperty +from ._models_py3 import Runbook +from ._models_py3 import RunbookAssociationProperty +from ._models_py3 import RunbookCreateOrUpdateDraftParameters +from ._models_py3 import RunbookCreateOrUpdateDraftProperties +from ._models_py3 import RunbookCreateOrUpdateParameters +from ._models_py3 import RunbookDraft +from ._models_py3 import RunbookDraftUndoEditResult +from ._models_py3 import RunbookListResult +from ._models_py3 import RunbookParameter +from ._models_py3 import RunbookUpdateParameters +from ._models_py3 import SUCScheduleProperties +from ._models_py3 import Schedule +from ._models_py3 import ScheduleAssociationProperty +from ._models_py3 import ScheduleCreateOrUpdateParameters +from ._models_py3 import ScheduleListResult +from ._models_py3 import ScheduleUpdateParameters +from ._models_py3 import Sku +from ._models_py3 import SoftwareUpdateConfiguration +from ._models_py3 import SoftwareUpdateConfigurationCollectionItem +from ._models_py3 import SoftwareUpdateConfigurationListResult +from ._models_py3 import SoftwareUpdateConfigurationMachineRun +from ._models_py3 import SoftwareUpdateConfigurationMachineRunListResult +from ._models_py3 import SoftwareUpdateConfigurationRun +from ._models_py3 import SoftwareUpdateConfigurationRunListResult +from ._models_py3 import SoftwareUpdateConfigurationRunTaskProperties +from ._models_py3 import SoftwareUpdateConfigurationRunTasks +from ._models_py3 import SoftwareUpdateConfigurationTasks +from ._models_py3 import SourceControl +from ._models_py3 import SourceControlCreateOrUpdateParameters +from ._models_py3 import SourceControlListResult +from ._models_py3 import SourceControlSecurityTokenProperties +from ._models_py3 import SourceControlSyncJob +from ._models_py3 import SourceControlSyncJobById +from ._models_py3 import SourceControlSyncJobCreateParameters +from ._models_py3 import SourceControlSyncJobListResult +from ._models_py3 import SourceControlSyncJobStream +from ._models_py3 import SourceControlSyncJobStreamById +from ._models_py3 import SourceControlSyncJobStreamsListBySyncJob +from ._models_py3 import SourceControlUpdateParameters +from ._models_py3 import Statistics +from ._models_py3 import StatisticsListResult +from ._models_py3 import SystemData +from ._models_py3 import TagSettingsProperties +from ._models_py3 import TargetProperties +from ._models_py3 import TaskProperties +from ._models_py3 import TestJob +from ._models_py3 import TestJobCreateParameters +from ._models_py3 import TrackedResource +from ._models_py3 import TypeField +from ._models_py3 import TypeFieldListResult +from ._models_py3 import UpdateConfiguration +from ._models_py3 import UpdateConfigurationNavigation +from ._models_py3 import Usage +from ._models_py3 import UsageCounterName +from ._models_py3 import UsageListResult +from ._models_py3 import Variable +from ._models_py3 import VariableCreateOrUpdateParameters +from ._models_py3 import VariableListResult +from ._models_py3 import VariableUpdateParameters +from ._models_py3 import Watcher +from ._models_py3 import WatcherListResult +from ._models_py3 import WatcherUpdateParameters +from ._models_py3 import Webhook +from ._models_py3 import WebhookCreateOrUpdateParameters +from ._models_py3 import WebhookListResult +from ._models_py3 import WebhookUpdateParameters +from ._models_py3 import WindowsProperties + from ._automation_client_enums import ( AgentRegistrationKeyName, @@ -338,7 +195,10 @@ AutomationKeyPermissions, ContentSourceType, CountType, + CreatedByType, DscConfigurationState, + EncryptionKeySourceType, + GraphRunbookType, GroupTypeEnum, HttpStatusCode, JobProvisioningState, @@ -348,6 +208,7 @@ ModuleProvisioningState, OperatingSystemType, ProvisioningState, + ResourceIdentityType, RunbookState, RunbookTypeEnum, ScheduleDay, @@ -359,8 +220,11 @@ TagOperators, TokenType, WindowsUpdateClasses, + WorkerType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Activity', 'ActivityListResult', @@ -382,6 +246,7 @@ 'CertificateCreateOrUpdateParameters', 'CertificateListResult', 'CertificateUpdateParameters', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'Connection', 'ConnectionCreateOrUpdateParameters', 'ConnectionListResult', @@ -420,12 +285,21 @@ 'DscReportError', 'DscReportResource', 'DscReportResourceNavigation', + 'EncryptionProperties', + 'EncryptionPropertiesIdentity', 'ErrorResponse', 'FieldDefinition', + 'GraphicalRunbookContent', 'HybridRunbookWorker', + 'HybridRunbookWorkerCreateParameters', 'HybridRunbookWorkerGroup', + 'HybridRunbookWorkerGroupCreateOrUpdateParameters', 'HybridRunbookWorkerGroupUpdateParameters', 'HybridRunbookWorkerGroupsListResult', + 'HybridRunbookWorkerLegacy', + 'HybridRunbookWorkerMoveParameters', + 'HybridRunbookWorkersListResult', + 'Identity', 'Job', 'JobCollectionItem', 'JobCreateParameters', @@ -438,6 +312,7 @@ 'JobStreamListResult', 'Key', 'KeyListResult', + 'KeyVaultProperties', 'LinkedWorkspace', 'LinuxProperties', 'Module', @@ -452,9 +327,16 @@ 'Operation', 'OperationDisplay', 'OperationListResult', + 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', + 'PrivateEndpointProperty', + 'PrivateLinkResource', + 'PrivateLinkResourceListResult', + 'PrivateLinkServiceConnectionStateProperty', 'ProxyResource', 'PythonPackageCreateParameters', 'PythonPackageUpdateParameters', + 'RawGraphicalRunbookContent', 'Resource', 'RunAsCredentialAssociationProperty', 'Runbook', @@ -498,6 +380,7 @@ 'SourceControlUpdateParameters', 'Statistics', 'StatisticsListResult', + 'SystemData', 'TagSettingsProperties', 'TargetProperties', 'TaskProperties', @@ -529,7 +412,10 @@ 'AutomationKeyPermissions', 'ContentSourceType', 'CountType', + 'CreatedByType', 'DscConfigurationState', + 'EncryptionKeySourceType', + 'GraphRunbookType', 'GroupTypeEnum', 'HttpStatusCode', 'JobProvisioningState', @@ -539,6 +425,7 @@ 'ModuleProvisioningState', 'OperatingSystemType', 'ProvisioningState', + 'ResourceIdentityType', 'RunbookState', 'RunbookTypeEnum', 'ScheduleDay', @@ -550,4 +437,7 @@ 'TagOperators', 'TokenType', 'WindowsUpdateClasses', + 'WorkerType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py index 2308a221239d..f3ec377e839d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_automation_client_enums.py @@ -6,34 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AgentRegistrationKeyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AgentRegistrationKeyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the agent registration key name - primary or secondary. """ PRIMARY = "primary" SECONDARY = "secondary" -class AutomationAccountState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationAccountState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets status of account. """ @@ -41,33 +25,42 @@ class AutomationAccountState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) UNAVAILABLE = "Unavailable" SUSPENDED = "Suspended" -class AutomationKeyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationKeyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automation key name. """ PRIMARY = "Primary" SECONDARY = "Secondary" -class AutomationKeyPermissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationKeyPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automation key permissions. """ READ = "Read" FULL = "Full" -class ContentSourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ContentSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the content source type. """ EMBEDDED_CONTENT = "embeddedContent" URI = "uri" -class CountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STATUS = "status" NODECONFIGURATION = "nodeconfiguration" -class DscConfigurationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DscConfigurationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the state of the configuration. """ @@ -75,14 +68,28 @@ class DscConfigurationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) EDIT = "Edit" PUBLISHED = "Published" -class GroupTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionKeySourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encryption Key Source + """ + + MICROSOFT_AUTOMATION = "Microsoft.Automation" + MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + +class GraphRunbookType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Runbook Type + """ + + GRAPH_POWER_SHELL = "GraphPowerShell" + GRAPH_POWER_SHELL_WORKFLOW = "GraphPowerShellWorkflow" + +class GroupTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the HybridWorkerGroup. """ USER = "User" SYSTEM = "System" -class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONTINUE_ENUM = "Continue" SWITCHING_PROTOCOLS = "SwitchingProtocols" @@ -132,7 +139,7 @@ class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GATEWAY_TIMEOUT = "GatewayTimeout" HTTP_VERSION_NOT_SUPPORTED = "HttpVersionNotSupported" -class JobProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the resource. """ @@ -141,7 +148,7 @@ class JobProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" PROCESSING = "Processing" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the status of the job. """ @@ -159,7 +166,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESUMING = "Resuming" REMOVING = "Removing" -class JobStreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStreamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the stream type. """ @@ -171,7 +178,7 @@ class JobStreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VERBOSE = "Verbose" ANY = "Any" -class LinuxUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LinuxUpdateClasses(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Update classifications included in the software update configuration. """ @@ -180,7 +187,7 @@ class LinuxUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SECURITY = "Security" OTHER = "Other" -class ModuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ModuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the provisioning state of the module. """ @@ -201,14 +208,14 @@ class ModuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum CANCELLED = "Cancelled" UPDATING = "Updating" -class OperatingSystemType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Target operating system for the software update configuration. """ WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the job. """ @@ -216,7 +223,16 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" RUNNING = "Running" -class RunbookState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class RunbookState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the state of the runbook. """ @@ -224,7 +240,7 @@ class RunbookState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EDIT = "Edit" PUBLISHED = "Published" -class RunbookTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RunbookTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the type of the runbook. """ @@ -234,8 +250,10 @@ class RunbookTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): POWER_SHELL = "PowerShell" GRAPH_POWER_SHELL_WORKFLOW = "GraphPowerShellWorkflow" GRAPH_POWER_SHELL = "GraphPowerShell" + PYTHON2 = "Python2" + PYTHON3 = "Python3" -class ScheduleDay(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScheduleDay(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. """ @@ -248,7 +266,7 @@ class ScheduleDay(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SATURDAY = "Saturday" SUNDAY = "Sunday" -class ScheduleFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScheduleFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the frequency of the schedule. """ @@ -257,16 +275,17 @@ class ScheduleFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): HOUR = "Hour" WEEK = "Week" MONTH = "Month" - MINUTE = "Minute" #: The minimum allowed interval for Minute schedules is 15 minutes. + #: The minimum allowed interval for Minute schedules is 15 minutes. + MINUTE = "Minute" -class SkuNameEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuNameEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name of the account. """ FREE = "Free" BASIC = "Basic" -class SourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The source type. Must be one of VsoGit, VsoTfvc, GitHub. """ @@ -274,35 +293,35 @@ class SourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VSO_TFVC = "VsoTfvc" GIT_HUB = "GitHub" -class StreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StreamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the sync job stream. """ ERROR = "Error" OUTPUT = "Output" -class SyncType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sync type. """ PARTIAL_SYNC = "PartialSync" FULL_SYNC = "FullSync" -class TagOperators(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagOperators(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Filter VMs by Any or All specified tags. """ ALL = "All" ANY = "Any" -class TokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The token type. Must be either PersonalAccessToken or Oauth. """ PERSONAL_ACCESS_TOKEN = "PersonalAccessToken" OAUTH = "Oauth" -class WindowsUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WindowsUpdateClasses(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Update classification included in the software update configuration. A comma separated string with required values """ @@ -316,3 +335,10 @@ class WindowsUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEFINITION = "Definition" TOOLS = "Tools" UPDATES = "Updates" + +class WorkerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the HybridWorker. + """ + + HYBRID_V1 = "HybridV1" + HYBRID_V2 = "HybridV2" diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models.py deleted file mode 100644 index aac6ffa75c5f..000000000000 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models.py +++ /dev/null @@ -1,6099 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Activity(msrest.serialization.Model): - """Definition of the activity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Gets or sets the id of the resource. - :type id: str - :ivar name: Gets the name of the activity. - :vartype name: str - :param definition: Gets or sets the user name of the activity. - :type definition: str - :param parameter_sets: Gets or sets the parameter sets of the activity. - :type parameter_sets: list[~azure.mgmt.automation.models.ActivityParameterSet] - :param output_types: Gets or sets the output types of the activity. - :type output_types: list[~azure.mgmt.automation.models.ActivityOutputType] - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'properties.definition', 'type': 'str'}, - 'parameter_sets': {'key': 'properties.parameterSets', 'type': '[ActivityParameterSet]'}, - 'output_types': {'key': 'properties.outputTypes', 'type': '[ActivityOutputType]'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Activity, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = None - self.definition = kwargs.get('definition', None) - self.parameter_sets = kwargs.get('parameter_sets', None) - self.output_types = kwargs.get('output_types', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ActivityListResult(msrest.serialization.Model): - """The response model for the list activity operation. - - :param value: Gets or sets a list of activities. - :type value: list[~azure.mgmt.automation.models.Activity] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Activity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ActivityOutputType(msrest.serialization.Model): - """Definition of the activity output type. - - :param name: Gets or sets the name of the activity output type. - :type name: str - :param type: Gets or sets the type of the activity output type. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityOutputType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class ActivityParameter(msrest.serialization.Model): - """Definition of the activity parameter. - - :param name: Gets or sets the name of the activity parameter. - :type name: str - :param type: Gets or sets the type of the activity parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value that indicates true if the parameter is - required. If the value is false, the parameter is optional. - :type is_mandatory: bool - :param is_dynamic: Gets or sets a Boolean value that indicates true if the parameter is - dynamic. - :type is_dynamic: bool - :param position: Gets or sets the position of the activity parameter. - :type position: long - :param value_from_pipeline: Gets or sets a Boolean value that indicates true if the parameter - can take values from the incoming pipeline objects. This setting is used if the cmdlet must - access the complete input object. false indicates that the parameter cannot take values from - the complete input object. - :type value_from_pipeline: bool - :param value_from_pipeline_by_property_name: Gets or sets a Boolean value that indicates true - if the parameter can be filled from a property of the incoming pipeline object that has the - same name as this parameter. false indicates that the parameter cannot be filled from the - incoming pipeline object property with the same name. - :type value_from_pipeline_by_property_name: bool - :param value_from_remaining_arguments: Gets or sets a Boolean value that indicates true if the - cmdlet parameter accepts all the remaining command-line arguments that are associated with this - parameter in the form of an array. false if the cmdlet parameter does not accept all the - remaining argument values. - :type value_from_remaining_arguments: bool - :param description: Gets or sets the description of the activity parameter. - :type description: str - :param validation_set: Gets or sets the validation set of activity parameter. - :type validation_set: list[~azure.mgmt.automation.models.ActivityParameterValidationSet] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'is_dynamic': {'key': 'isDynamic', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'long'}, - 'value_from_pipeline': {'key': 'valueFromPipeline', 'type': 'bool'}, - 'value_from_pipeline_by_property_name': {'key': 'valueFromPipelineByPropertyName', 'type': 'bool'}, - 'value_from_remaining_arguments': {'key': 'valueFromRemainingArguments', 'type': 'bool'}, - 'description': {'key': 'description', 'type': 'str'}, - 'validation_set': {'key': 'validationSet', 'type': '[ActivityParameterValidationSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.is_dynamic = kwargs.get('is_dynamic', None) - self.position = kwargs.get('position', None) - self.value_from_pipeline = kwargs.get('value_from_pipeline', None) - self.value_from_pipeline_by_property_name = kwargs.get('value_from_pipeline_by_property_name', None) - self.value_from_remaining_arguments = kwargs.get('value_from_remaining_arguments', None) - self.description = kwargs.get('description', None) - self.validation_set = kwargs.get('validation_set', None) - - -class ActivityParameterSet(msrest.serialization.Model): - """Definition of the activity parameter set. - - :param name: Gets or sets the name of the activity parameter set. - :type name: str - :param parameters: Gets or sets the parameters of the activity parameter set. - :type parameters: list[~azure.mgmt.automation.models.ActivityParameter] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ActivityParameter]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameterSet, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.parameters = kwargs.get('parameters', None) - - -class ActivityParameterValidationSet(msrest.serialization.Model): - """Definition of the activity parameter validation set. - - :param member_value: Gets or sets the name of the activity parameter validation set member. - :type member_value: str - """ - - _attribute_map = { - 'member_value': {'key': 'memberValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameterValidationSet, self).__init__(**kwargs) - self.member_value = kwargs.get('member_value', None) - - -class AdvancedSchedule(msrest.serialization.Model): - """The properties of the create Advanced Schedule. - - :param week_days: Days of the week that the job should execute on. - :type week_days: list[str] - :param month_days: Days of the month that the job should execute on. Must be between 1 and 31. - :type month_days: list[int] - :param monthly_occurrences: Occurrences of days within a month. - :type monthly_occurrences: - list[~azure.mgmt.automation.models.AdvancedScheduleMonthlyOccurrence] - """ - - _attribute_map = { - 'week_days': {'key': 'weekDays', 'type': '[str]'}, - 'month_days': {'key': 'monthDays', 'type': '[int]'}, - 'monthly_occurrences': {'key': 'monthlyOccurrences', 'type': '[AdvancedScheduleMonthlyOccurrence]'}, - } - - def __init__( - self, - **kwargs - ): - super(AdvancedSchedule, self).__init__(**kwargs) - self.week_days = kwargs.get('week_days', None) - self.month_days = kwargs.get('month_days', None) - self.monthly_occurrences = kwargs.get('monthly_occurrences', None) - - -class AdvancedScheduleMonthlyOccurrence(msrest.serialization.Model): - """The properties of the create advanced schedule monthly occurrence. - - :param occurrence: Occurrence of the week within the month. Must be between 1 and 5. - :type occurrence: int - :param day: Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, - saturday, sunday. Possible values include: "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday", "Sunday". - :type day: str or ~azure.mgmt.automation.models.ScheduleDay - """ - - _attribute_map = { - 'occurrence': {'key': 'occurrence', 'type': 'int'}, - 'day': {'key': 'day', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdvancedScheduleMonthlyOccurrence, self).__init__(**kwargs) - self.occurrence = kwargs.get('occurrence', None) - self.day = kwargs.get('day', None) - - -class AgentRegistration(msrest.serialization.Model): - """Definition of the agent registration information type. - - :param dsc_meta_configuration: Gets or sets the dsc meta configuration. - :type dsc_meta_configuration: str - :param endpoint: Gets or sets the dsc server endpoint. - :type endpoint: str - :param keys: Gets or sets the agent registration keys. - :type keys: ~azure.mgmt.automation.models.AgentRegistrationKeys - :param id: Gets or sets the id. - :type id: str - """ - - _attribute_map = { - 'dsc_meta_configuration': {'key': 'dscMetaConfiguration', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - 'keys': {'key': 'keys', 'type': 'AgentRegistrationKeys'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistration, self).__init__(**kwargs) - self.dsc_meta_configuration = kwargs.get('dsc_meta_configuration', None) - self.endpoint = kwargs.get('endpoint', None) - self.keys = kwargs.get('keys', None) - self.id = kwargs.get('id', None) - - -class AgentRegistrationKeys(msrest.serialization.Model): - """Definition of the agent registration keys. - - :param primary: Gets or sets the primary key. - :type primary: str - :param secondary: Gets or sets the secondary key. - :type secondary: str - """ - - _attribute_map = { - 'primary': {'key': 'primary', 'type': 'str'}, - 'secondary': {'key': 'secondary', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistrationKeys, self).__init__(**kwargs) - self.primary = kwargs.get('primary', None) - self.secondary = kwargs.get('secondary', None) - - -class AgentRegistrationRegenerateKeyParameter(msrest.serialization.Model): - """The parameters supplied to the regenerate keys operation. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. Gets or sets the agent registration key name - primary or secondary. - Possible values include: "primary", "secondary". - :type key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName - """ - - _validation = { - 'key_name': {'required': True}, - } - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistrationRegenerateKeyParameter, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - - -class Resource(msrest.serialization.Model): - """The core properties of ARM resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - - -class AutomationAccount(TrackedResource): - """Definition of the automation account type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param sku: Gets or sets the SKU of account. - :type sku: ~azure.mgmt.automation.models.Sku - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :ivar state: Gets status of account. Possible values include: "Ok", "Unavailable", "Suspended". - :vartype state: str or ~azure.mgmt.automation.models.AutomationAccountState - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccount, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.sku = kwargs.get('sku', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.state = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class AutomationAccountCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update automation account operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - - -class AutomationAccountListResult(msrest.serialization.Model): - """The response model for the list account operation. - - :param value: Gets or sets list of accounts. - :type value: list[~azure.mgmt.automation.models.AutomationAccount] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AutomationAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AutomationAccountUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update automation account operation. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - - -class AzureQueryProperties(msrest.serialization.Model): - """Azure query for the update configuration. - - :param scope: List of Subscription or Resource Group ARM Ids. - :type scope: list[str] - :param locations: List of locations to scope the query to. - :type locations: list[str] - :param tag_settings: Tag settings for the VM. - :type tag_settings: ~azure.mgmt.automation.models.TagSettingsProperties - """ - - _attribute_map = { - 'scope': {'key': 'scope', 'type': '[str]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'tag_settings': {'key': 'tagSettings', 'type': 'TagSettingsProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureQueryProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.locations = kwargs.get('locations', None) - self.tag_settings = kwargs.get('tag_settings', None) - - -class Certificate(Resource): - """Definition of the certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar thumbprint: Gets the thumbprint of the certificate. - :vartype thumbprint: str - :ivar expiry_time: Gets the expiry time of the certificate. - :vartype expiry_time: ~datetime.datetime - :ivar is_exportable: Gets the is exportable flag of the certificate. - :vartype is_exportable: bool - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'expiry_time': {'readonly': True}, - 'is_exportable': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'is_exportable': {'key': 'properties.isExportable', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Certificate, self).__init__(**kwargs) - self.thumbprint = None - self.expiry_time = None - self.is_exportable = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class CertificateCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update or replace certificate operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the certificate. - :type name: str - :param base64_value: Required. Gets or sets the base64 encoded value of the certificate. - :type base64_value: str - :param description: Gets or sets the description of the certificate. - :type description: str - :param thumbprint: Gets or sets the thumbprint of the certificate. - :type thumbprint: str - :param is_exportable: Gets or sets the is exportable flag of the certificate. - :type is_exportable: bool - """ - - _validation = { - 'name': {'required': True}, - 'base64_value': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'base64_value': {'key': 'properties.base64Value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'is_exportable': {'key': 'properties.isExportable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.base64_value = kwargs['base64_value'] - self.description = kwargs.get('description', None) - self.thumbprint = kwargs.get('thumbprint', None) - self.is_exportable = kwargs.get('is_exportable', None) - - -class CertificateListResult(msrest.serialization.Model): - """The response model for the list certificate operation. - - :param value: Gets or sets a list of certificates. - :type value: list[~azure.mgmt.automation.models.Certificate] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Certificate]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CertificateUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update certificate operation. - - :param name: Gets or sets the name of the certificate. - :type name: str - :param description: Gets or sets the description of the certificate. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - - -class Connection(Resource): - """Definition of the connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param connection_type: Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty - :ivar field_definition_values: Gets the field definition values of the connection. - :vartype field_definition_values: dict[str, str] - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'field_definition_values': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'connection_type': {'key': 'properties.connectionType', 'type': 'ConnectionTypeAssociationProperty'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Connection, self).__init__(**kwargs) - self.connection_type = kwargs.get('connection_type', None) - self.field_definition_values = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class ConnectionCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update connection operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param connection_type: Required. Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty - :param field_definition_values: Gets or sets the field definition properties of the connection. - :type field_definition_values: dict[str, str] - """ - - _validation = { - 'name': {'required': True}, - 'connection_type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'connection_type': {'key': 'properties.connectionType', 'type': 'ConnectionTypeAssociationProperty'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.description = kwargs.get('description', None) - self.connection_type = kwargs['connection_type'] - self.field_definition_values = kwargs.get('field_definition_values', None) - - -class ConnectionListResult(msrest.serialization.Model): - """The response model for the list connection operation. - - :param value: Gets or sets a list of connection. - :type value: list[~azure.mgmt.automation.models.Connection] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Connection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ConnectionType(msrest.serialization.Model): - """Definition of the connection type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the resource. - :vartype id: str - :ivar name: Gets the name of the connection type. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool - :ivar field_definitions: Gets the field definitions of the connection type. - :vartype field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'field_definitions': {'readonly': True}, - 'creation_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'field_definitions': {'key': 'properties.fieldDefinitions', 'type': '{FieldDefinition}'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionType, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.is_global = kwargs.get('is_global', None) - self.field_definitions = None - self.creation_time = None - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ConnectionTypeAssociationProperty(msrest.serialization.Model): - """The connection type property associated with the entity. - - :param name: Gets or sets the name of the connection type. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ConnectionTypeCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update connection type operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the connection type. - :type name: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool - :param field_definitions: Required. Gets or sets the field definitions of the connection type. - :type field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] - """ - - _validation = { - 'name': {'required': True}, - 'field_definitions': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'field_definitions': {'key': 'properties.fieldDefinitions', 'type': '{FieldDefinition}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.is_global = kwargs.get('is_global', None) - self.field_definitions = kwargs['field_definitions'] - - -class ConnectionTypeListResult(msrest.serialization.Model): - """The response model for the list connection type operation. - - :param value: Gets or sets a list of connection types. - :type value: list[~azure.mgmt.automation.models.ConnectionType] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectionType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ConnectionUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update connection operation. - - :param name: Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param field_definition_values: Gets or sets the field definition values of the connection. - :type field_definition_values: dict[str, str] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.field_definition_values = kwargs.get('field_definition_values', None) - - -class ContentHash(msrest.serialization.Model): - """Definition of the runbook property type. - - All required parameters must be populated in order to send to Azure. - - :param algorithm: Required. Gets or sets the content hash algorithm used to hash the content. - :type algorithm: str - :param value: Required. Gets or sets expected hash value of the content. - :type value: str - """ - - _validation = { - 'algorithm': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'algorithm': {'key': 'algorithm', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentHash, self).__init__(**kwargs) - self.algorithm = kwargs['algorithm'] - self.value = kwargs['value'] - - -class ContentLink(msrest.serialization.Model): - """Definition of the content link. - - :param uri: Gets or sets the uri of the runbook content. - :type uri: str - :param content_hash: Gets or sets the hash. - :type content_hash: ~azure.mgmt.automation.models.ContentHash - :param version: Gets or sets the version of the content. - :type version: str - """ - - _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_hash': {'key': 'contentHash', 'type': 'ContentHash'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) - self.content_hash = kwargs.get('content_hash', None) - self.version = kwargs.get('version', None) - - -class ContentSource(msrest.serialization.Model): - """Definition of the content source. - - :param hash: Gets or sets the hash. - :type hash: ~azure.mgmt.automation.models.ContentHash - :param type: Gets or sets the content source type. Possible values include: "embeddedContent", - "uri". - :type type: str or ~azure.mgmt.automation.models.ContentSourceType - :param value: Gets or sets the value of the content. This is based on the content source type. - :type value: str - :param version: Gets or sets the version of the content. - :type version: str - """ - - _attribute_map = { - 'hash': {'key': 'hash', 'type': 'ContentHash'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentSource, self).__init__(**kwargs) - self.hash = kwargs.get('hash', None) - self.type = kwargs.get('type', None) - self.value = kwargs.get('value', None) - self.version = kwargs.get('version', None) - - -class Credential(Resource): - """Definition of the credential. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar user_name: Gets the user name of the credential. - :vartype user_name: str - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_name': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Credential, self).__init__(**kwargs) - self.user_name = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class CredentialCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update credential operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the credential. - :type name: str - :param user_name: Required. Gets or sets the user name of the credential. - :type user_name: str - :param password: Required. Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str - """ - - _validation = { - 'name': {'required': True}, - 'user_name': {'required': True}, - 'password': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.user_name = kwargs['user_name'] - self.password = kwargs['password'] - self.description = kwargs.get('description', None) - - -class CredentialListResult(msrest.serialization.Model): - """The response model for the list credential operation. - - :param value: Gets or sets a list of credentials. - :type value: list[~azure.mgmt.automation.models.Credential] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Credential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CredentialUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the Update credential operation. - - :param name: Gets or sets the name of the credential. - :type name: str - :param user_name: Gets or sets the user name of the credential. - :type user_name: str - :param password: Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.description = kwargs.get('description', None) - - -class DscCompilationJob(Resource): - """Definition of the Dsc Compilation job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param configuration: Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :ivar started_by: Gets the compilation job started by. - :vartype started_by: str - :ivar job_id: Gets the id of the job. - :vartype job_id: str - :ivar creation_time: Gets the creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The current provisioning state of the job. Possible values include: - "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str - :ivar start_time: Gets the start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets the end time of the job. - :vartype end_time: ~datetime.datetime - :ivar exception: Gets the exception of the job. - :vartype exception: str - :ivar last_modified_time: Gets the last modified time of the job. - :vartype last_modified_time: ~datetime.datetime - :ivar last_status_modified_time: Gets the last status modified time of the job. - :vartype last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'started_by': {'readonly': True}, - 'job_id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'exception': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_status_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'started_by': {'key': 'properties.startedBy', 'type': 'str'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'properties.lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJob, self).__init__(**kwargs) - self.configuration = kwargs.get('configuration', None) - self.started_by = None - self.job_id = None - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.run_on = kwargs.get('run_on', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.start_time = None - self.end_time = None - self.exception = None - self.last_modified_time = None - self.last_status_modified_time = None - self.parameters = kwargs.get('parameters', None) - - -class DscCompilationJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create compilation job operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param configuration: Required. Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _validation = { - 'configuration': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJobCreateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.configuration = kwargs['configuration'] - self.parameters = kwargs.get('parameters', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscCompilationJobListResult(msrest.serialization.Model): - """The response model for the list job operation. - - :param value: Gets or sets a list of Dsc Compilation jobs. - :type value: list[~azure.mgmt.automation.models.DscCompilationJob] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscCompilationJob]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJobListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DscConfiguration(TrackedResource): - """Definition of the configuration type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :ivar provisioning_state: Gets or sets the provisioning state of the configuration. Default - value: "Succeeded". - :vartype provisioning_state: str - :param job_count: Gets or sets the job count of the configuration. - :type job_count: int - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param state: Gets or sets the state of the configuration. Possible values include: "New", - "Edit", "Published". - :type state: str or ~azure.mgmt.automation.models.DscConfigurationState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param node_configuration_count: Gets the number of compiled node configurations. - :type node_configuration_count: int - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'job_count': {'key': 'properties.jobCount', 'type': 'int'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'node_configuration_count': {'key': 'properties.nodeConfigurationCount', 'type': 'int'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - provisioning_state = "Succeeded" - - def __init__( - self, - **kwargs - ): - super(DscConfiguration, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.job_count = kwargs.get('job_count', None) - self.parameters = kwargs.get('parameters', None) - self.source = kwargs.get('source', None) - self.state = kwargs.get('state', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.node_configuration_count = kwargs.get('node_configuration_count', None) - self.description = kwargs.get('description', None) - - -class DscConfigurationAssociationProperty(msrest.serialization.Model): - """The Dsc configuration property associated with the entity. - - :param name: Gets or sets the name of the Dsc configuration. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class DscConfigurationCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update configuration operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Required. Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str - """ - - _validation = { - 'source': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.source = kwargs['source'] - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class DscConfigurationListResult(msrest.serialization.Model): - """The response model for the list configuration operation. - - :param value: Gets or sets a list of configurations. - :type value: list[~azure.mgmt.automation.models.DscConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of configurations matching filter criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscConfigurationParameter(msrest.serialization.Model): - """Definition of the configuration parameter type. - - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'int'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationParameter, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.position = kwargs.get('position', None) - self.default_value = kwargs.get('default_value', None) - - -class DscConfigurationUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update configuration operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.source = kwargs.get('source', None) - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class DscMetaConfiguration(msrest.serialization.Model): - """Definition of the DSC Meta Configuration. - - :param configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins value - of the meta configuration. - :type configuration_mode_frequency_mins: int - :param reboot_node_if_needed: Gets or sets the RebootNodeIfNeeded value of the meta - configuration. - :type reboot_node_if_needed: bool - :param configuration_mode: Gets or sets the ConfigurationMode value of the meta configuration. - :type configuration_mode: str - :param action_after_reboot: Gets or sets the ActionAfterReboot value of the meta configuration. - :type action_after_reboot: str - :param certificate_id: Gets or sets the CertificateId value of the meta configuration. - :type certificate_id: str - :param refresh_frequency_mins: Gets or sets the RefreshFrequencyMins value of the meta - configuration. - :type refresh_frequency_mins: int - :param allow_module_overwrite: Gets or sets the AllowModuleOverwrite value of the meta - configuration. - :type allow_module_overwrite: bool - """ - - _attribute_map = { - 'configuration_mode_frequency_mins': {'key': 'configurationModeFrequencyMins', 'type': 'int'}, - 'reboot_node_if_needed': {'key': 'rebootNodeIfNeeded', 'type': 'bool'}, - 'configuration_mode': {'key': 'configurationMode', 'type': 'str'}, - 'action_after_reboot': {'key': 'actionAfterReboot', 'type': 'str'}, - 'certificate_id': {'key': 'certificateId', 'type': 'str'}, - 'refresh_frequency_mins': {'key': 'refreshFrequencyMins', 'type': 'int'}, - 'allow_module_overwrite': {'key': 'allowModuleOverwrite', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscMetaConfiguration, self).__init__(**kwargs) - self.configuration_mode_frequency_mins = kwargs.get('configuration_mode_frequency_mins', None) - self.reboot_node_if_needed = kwargs.get('reboot_node_if_needed', None) - self.configuration_mode = kwargs.get('configuration_mode', None) - self.action_after_reboot = kwargs.get('action_after_reboot', None) - self.certificate_id = kwargs.get('certificate_id', None) - self.refresh_frequency_mins = kwargs.get('refresh_frequency_mins', None) - self.allow_module_overwrite = kwargs.get('allow_module_overwrite', None) - - -class DscNode(Resource): - """Definition of a DscNode. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param last_seen: Gets or sets the last seen time of the node. - :type last_seen: ~datetime.datetime - :param registration_time: Gets or sets the registration time of the node. - :type registration_time: ~datetime.datetime - :param ip: Gets or sets the ip of the node. - :type ip: str - :param account_id: Gets or sets the account id of the node. - :type account_id: str - :param status: Gets or sets the status of the node. - :type status: str - :param node_id: Gets or sets the node id. - :type node_id: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param total_count: Gets the total number of records matching filter criteria. - :type total_count: int - :param extension_handler: Gets or sets the list of extensionHandler properties for a Node. - :type extension_handler: - list[~azure.mgmt.automation.models.DscNodeExtensionHandlerAssociationProperty] - :param name_properties_node_configuration_name: Gets or sets the name of the dsc node - configuration. - :type name_properties_node_configuration_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_seen': {'key': 'properties.lastSeen', 'type': 'iso-8601'}, - 'registration_time': {'key': 'properties.registrationTime', 'type': 'iso-8601'}, - 'ip': {'key': 'properties.ip', 'type': 'str'}, - 'account_id': {'key': 'properties.accountId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'node_id': {'key': 'properties.nodeId', 'type': 'str'}, - 'etag': {'key': 'properties.etag', 'type': 'str'}, - 'total_count': {'key': 'properties.totalCount', 'type': 'int'}, - 'extension_handler': {'key': 'properties.extensionHandler', 'type': '[DscNodeExtensionHandlerAssociationProperty]'}, - 'name_properties_node_configuration_name': {'key': 'properties.nodeConfiguration.name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNode, self).__init__(**kwargs) - self.last_seen = kwargs.get('last_seen', None) - self.registration_time = kwargs.get('registration_time', None) - self.ip = kwargs.get('ip', None) - self.account_id = kwargs.get('account_id', None) - self.status = kwargs.get('status', None) - self.node_id = kwargs.get('node_id', None) - self.etag = kwargs.get('etag', None) - self.total_count = kwargs.get('total_count', None) - self.extension_handler = kwargs.get('extension_handler', None) - self.name_properties_node_configuration_name = kwargs.get('name_properties_node_configuration_name', None) - - -class DscNodeConfiguration(Resource): - """Definition of the dsc node configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param creation_time: Gets or sets creation time. - :type creation_time: ~datetime.datetime - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param source: Source of node configuration. - :type source: str - :param node_count: Number of nodes with this node configuration assigned. - :type node_count: long - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'long'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfiguration, self).__init__(**kwargs) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.creation_time = kwargs.get('creation_time', None) - self.configuration = kwargs.get('configuration', None) - self.source = kwargs.get('source', None) - self.node_count = kwargs.get('node_count', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscNodeConfigurationCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update node configuration operation. - - :param name: Name of the node configuration. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tags = kwargs.get('tags', None) - self.source = kwargs.get('source', None) - self.configuration = kwargs.get('configuration', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscNodeConfigurationListResult(msrest.serialization.Model): - """The response model for the list job operation. - - :param value: Gets or sets a list of Dsc node configurations. - :type value: list[~azure.mgmt.automation.models.DscNodeConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets or sets the total rows in query. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNodeConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscNodeExtensionHandlerAssociationProperty(msrest.serialization.Model): - """The dsc extensionHandler property associated with the node. - - :param name: Gets or sets the name of the extension handler. - :type name: str - :param version: Gets or sets the version of the extension handler. - :type version: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeExtensionHandlerAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.version = kwargs.get('version', None) - - -class DscNodeListResult(msrest.serialization.Model): - """The response model for the list dsc nodes operation. - - :param value: Gets or sets a list of dsc nodes. - :type value: list[~azure.mgmt.automation.models.DscNode] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of nodes matching filter criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNode]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscNodeReport(msrest.serialization.Model): - """Definition of the dsc node report type. - - :param end_time: Gets or sets the end time of the node report. - :type end_time: ~datetime.datetime - :param last_modified_time: Gets or sets the lastModifiedTime of the node report. - :type last_modified_time: ~datetime.datetime - :param start_time: Gets or sets the start time of the node report. - :type start_time: ~datetime.datetime - :param type: Gets or sets the type of the node report. - :type type: str - :param report_id: Gets or sets the id of the node report. - :type report_id: str - :param status: Gets or sets the status of the node report. - :type status: str - :param refresh_mode: Gets or sets the refreshMode of the node report. - :type refresh_mode: str - :param reboot_requested: Gets or sets the rebootRequested of the node report. - :type reboot_requested: str - :param report_format_version: Gets or sets the reportFormatVersion of the node report. - :type report_format_version: str - :param configuration_version: Gets or sets the configurationVersion of the node report. - :type configuration_version: str - :param id: Gets or sets the id. - :type id: str - :param errors: Gets or sets the errors for the node report. - :type errors: list[~azure.mgmt.automation.models.DscReportError] - :param resources: Gets or sets the resource for the node report. - :type resources: list[~azure.mgmt.automation.models.DscReportResource] - :param meta_configuration: Gets or sets the metaConfiguration of the node at the time of the - report. - :type meta_configuration: ~azure.mgmt.automation.models.DscMetaConfiguration - :param host_name: Gets or sets the hostname of the node that sent the report. - :type host_name: str - :param i_pv4_addresses: Gets or sets the IPv4 address of the node that sent the report. - :type i_pv4_addresses: list[str] - :param i_pv6_addresses: Gets or sets the IPv6 address of the node that sent the report. - :type i_pv6_addresses: list[str] - :param number_of_resources: Gets or sets the number of resource in the node report. - :type number_of_resources: int - :param raw_errors: Gets or sets the unparsed errors for the node report. - :type raw_errors: str - """ - - _attribute_map = { - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'type': {'key': 'type', 'type': 'str'}, - 'report_id': {'key': 'reportId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'refresh_mode': {'key': 'refreshMode', 'type': 'str'}, - 'reboot_requested': {'key': 'rebootRequested', 'type': 'str'}, - 'report_format_version': {'key': 'reportFormatVersion', 'type': 'str'}, - 'configuration_version': {'key': 'configurationVersion', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[DscReportError]'}, - 'resources': {'key': 'resources', 'type': '[DscReportResource]'}, - 'meta_configuration': {'key': 'metaConfiguration', 'type': 'DscMetaConfiguration'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'i_pv4_addresses': {'key': 'iPV4Addresses', 'type': '[str]'}, - 'i_pv6_addresses': {'key': 'iPV6Addresses', 'type': '[str]'}, - 'number_of_resources': {'key': 'numberOfResources', 'type': 'int'}, - 'raw_errors': {'key': 'rawErrors', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeReport, self).__init__(**kwargs) - self.end_time = kwargs.get('end_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.start_time = kwargs.get('start_time', None) - self.type = kwargs.get('type', None) - self.report_id = kwargs.get('report_id', None) - self.status = kwargs.get('status', None) - self.refresh_mode = kwargs.get('refresh_mode', None) - self.reboot_requested = kwargs.get('reboot_requested', None) - self.report_format_version = kwargs.get('report_format_version', None) - self.configuration_version = kwargs.get('configuration_version', None) - self.id = kwargs.get('id', None) - self.errors = kwargs.get('errors', None) - self.resources = kwargs.get('resources', None) - self.meta_configuration = kwargs.get('meta_configuration', None) - self.host_name = kwargs.get('host_name', None) - self.i_pv4_addresses = kwargs.get('i_pv4_addresses', None) - self.i_pv6_addresses = kwargs.get('i_pv6_addresses', None) - self.number_of_resources = kwargs.get('number_of_resources', None) - self.raw_errors = kwargs.get('raw_errors', None) - - -class DscNodeReportListResult(msrest.serialization.Model): - """The response model for the list dsc nodes operation. - - :param value: Gets or sets a list of dsc node reports. - :type value: list[~azure.mgmt.automation.models.DscNodeReport] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNodeReport]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeReportListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DscNodeUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update dsc node operation. - - :param node_id: Gets or sets the id of the dsc node. - :type node_id: str - :param properties: - :type properties: ~azure.mgmt.automation.models.DscNodeUpdateParametersProperties - """ - - _attribute_map = { - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DscNodeUpdateParametersProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeUpdateParameters, self).__init__(**kwargs) - self.node_id = kwargs.get('node_id', None) - self.properties = kwargs.get('properties', None) - - -class DscNodeUpdateParametersProperties(msrest.serialization.Model): - """DscNodeUpdateParametersProperties. - - :param name: Gets or sets the name of the dsc node configuration. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'nodeConfiguration.name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeUpdateParametersProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class DscReportError(msrest.serialization.Model): - """Definition of the dsc node report error type. - - :param error_source: Gets or sets the source of the error. - :type error_source: str - :param resource_id: Gets or sets the resource ID which generated the error. - :type resource_id: str - :param error_code: Gets or sets the error code. - :type error_code: str - :param error_message: Gets or sets the error message. - :type error_message: str - :param locale: Gets or sets the locale of the error. - :type locale: str - :param error_details: Gets or sets the error details. - :type error_details: str - """ - - _attribute_map = { - 'error_source': {'key': 'errorSource', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'locale': {'key': 'locale', 'type': 'str'}, - 'error_details': {'key': 'errorDetails', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportError, self).__init__(**kwargs) - self.error_source = kwargs.get('error_source', None) - self.resource_id = kwargs.get('resource_id', None) - self.error_code = kwargs.get('error_code', None) - self.error_message = kwargs.get('error_message', None) - self.locale = kwargs.get('locale', None) - self.error_details = kwargs.get('error_details', None) - - -class DscReportResource(msrest.serialization.Model): - """Definition of the DSC Report Resource. - - :param resource_id: Gets or sets the ID of the resource. - :type resource_id: str - :param source_info: Gets or sets the source info of the resource. - :type source_info: str - :param depends_on: Gets or sets the Resource Navigation values for resources the resource - depends on. - :type depends_on: list[~azure.mgmt.automation.models.DscReportResourceNavigation] - :param module_name: Gets or sets the module name of the resource. - :type module_name: str - :param module_version: Gets or sets the module version of the resource. - :type module_version: str - :param resource_name: Gets or sets the name of the resource. - :type resource_name: str - :param error: Gets or sets the error of the resource. - :type error: str - :param status: Gets or sets the status of the resource. - :type status: str - :param duration_in_seconds: Gets or sets the duration in seconds for the resource. - :type duration_in_seconds: float - :param start_date: Gets or sets the start date of the resource. - :type start_date: ~datetime.datetime - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'source_info': {'key': 'sourceInfo', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[DscReportResourceNavigation]'}, - 'module_name': {'key': 'moduleName', 'type': 'str'}, - 'module_version': {'key': 'moduleVersion', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'duration_in_seconds': {'key': 'durationInSeconds', 'type': 'float'}, - 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportResource, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.source_info = kwargs.get('source_info', None) - self.depends_on = kwargs.get('depends_on', None) - self.module_name = kwargs.get('module_name', None) - self.module_version = kwargs.get('module_version', None) - self.resource_name = kwargs.get('resource_name', None) - self.error = kwargs.get('error', None) - self.status = kwargs.get('status', None) - self.duration_in_seconds = kwargs.get('duration_in_seconds', None) - self.start_date = kwargs.get('start_date', None) - - -class DscReportResourceNavigation(msrest.serialization.Model): - """Navigation for DSC Report Resource. - - :param resource_id: Gets or sets the ID of the resource to navigate to. - :type resource_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportResourceNavigation, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response of an operation failure. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class FieldDefinition(msrest.serialization.Model): - """Definition of the connection fields. - - All required parameters must be populated in order to send to Azure. - - :param is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. - :type is_encrypted: bool - :param is_optional: Gets or sets the isOptional flag of the connection field definition. - :type is_optional: bool - :param type: Required. Gets or sets the type of the connection field definition. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'is_encrypted': {'key': 'isEncrypted', 'type': 'bool'}, - 'is_optional': {'key': 'isOptional', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FieldDefinition, self).__init__(**kwargs) - self.is_encrypted = kwargs.get('is_encrypted', None) - self.is_optional = kwargs.get('is_optional', None) - self.type = kwargs['type'] - - -class HybridRunbookWorker(msrest.serialization.Model): - """Definition of hybrid runbook worker. - - :param name: Gets or sets the worker machine name. - :type name: str - :param ip: Gets or sets the assigned machine IP address. - :type ip: str - :param registration_time: Gets or sets the registration time of the worker machine. - :type registration_time: ~datetime.datetime - :param last_seen_date_time: Last Heartbeat from the Worker. - :type last_seen_date_time: ~datetime.datetime - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, - 'registration_time': {'key': 'registrationTime', 'type': 'iso-8601'}, - 'last_seen_date_time': {'key': 'lastSeenDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorker, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.ip = kwargs.get('ip', None) - self.registration_time = kwargs.get('registration_time', None) - self.last_seen_date_time = kwargs.get('last_seen_date_time', None) - - -class HybridRunbookWorkerGroup(msrest.serialization.Model): - """Definition of hybrid runbook worker group. - - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the name of the group. - :type name: str - :param hybrid_runbook_workers: Gets or sets the list of hybrid runbook workers. - :type hybrid_runbook_workers: list[~azure.mgmt.automation.models.HybridRunbookWorker] - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty - :param group_type: Type of the HybridWorkerGroup. Possible values include: "User", "System". - :type group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'hybrid_runbook_workers': {'key': 'hybridRunbookWorkers', 'type': '[HybridRunbookWorker]'}, - 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, - 'group_type': {'key': 'groupType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroup, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.hybrid_runbook_workers = kwargs.get('hybrid_runbook_workers', None) - self.credential = kwargs.get('credential', None) - self.group_type = kwargs.get('group_type', None) - - -class HybridRunbookWorkerGroupsListResult(msrest.serialization.Model): - """The response model for the list hybrid runbook worker groups. - - :param value: Gets or sets a list of hybrid runbook worker groups. - :type value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HybridRunbookWorkerGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class HybridRunbookWorkerGroupUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the update operation. - - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty - """ - - _attribute_map = { - 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroupUpdateParameters, self).__init__(**kwargs) - self.credential = kwargs.get('credential', None) - - -class Job(Resource): - """Definition of the job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param started_by: Gets or sets the job started by. - :type started_by: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param job_id: Gets or sets the id of the job. - :type job_id: str - :param creation_time: Gets or sets the creation time of the job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str - :param start_time: Gets or sets the start time of the job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param provisioning_state: The current provisioning state of the job. Possible values include: - "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'started_by': {'key': 'properties.startedBy', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'properties.lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.runbook = kwargs.get('runbook', None) - self.started_by = kwargs.get('started_by', None) - self.run_on = kwargs.get('run_on', None) - self.job_id = kwargs.get('job_id', None) - self.creation_time = kwargs.get('creation_time', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.exception = kwargs.get('exception', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_status_modified_time = kwargs.get('last_status_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class JobCollectionItem(Resource): - """Job collection item properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar runbook: The runbook association. - :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :ivar job_id: The id of the job. - :vartype job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :ivar status: The status of the job. Possible values include: "New", "Activating", "Running", - "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", "Suspending", - "Stopping", "Resuming", "Removing". - :vartype status: str or ~azure.mgmt.automation.models.JobStatus - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :ivar last_modified_time: The last modified time of the job. - :vartype last_modified_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state of a resource. - :vartype provisioning_state: str - :param run_on: Specifies the runOn group name where the job was executed. - :type run_on: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'runbook': {'readonly': True}, - 'job_id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCollectionItem, self).__init__(**kwargs) - self.runbook = None - self.job_id = None - self.creation_time = None - self.status = None - self.start_time = None - self.end_time = None - self.last_modified_time = None - self.provisioning_state = None - self.run_on = kwargs.get('run_on', None) - - -class JobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create job operation. - - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - """ - - _attribute_map = { - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCreateParameters, self).__init__(**kwargs) - self.runbook = kwargs.get('runbook', None) - self.parameters = kwargs.get('parameters', None) - self.run_on = kwargs.get('run_on', None) - - -class JobListResultV2(msrest.serialization.Model): - """The response model for the list job operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of jobs. - :type value: list[~azure.mgmt.automation.models.JobCollectionItem] - :ivar next_link: The link to the next page. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobCollectionItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobListResultV2, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class JobNavigation(msrest.serialization.Model): - """Software update configuration machine run job navigation properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the job associated with the software update configuration run. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobNavigation, self).__init__(**kwargs) - self.id = None - - -class JobSchedule(msrest.serialization.Model): - """Definition of the job schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the resource. - :vartype id: str - :ivar name: Gets the name of the variable. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param job_schedule_id: Gets or sets the id of job schedule. - :type job_schedule_id: str - :param schedule: Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job schedule. - :type parameters: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'job_schedule_id': {'key': 'properties.jobScheduleId', 'type': 'str'}, - 'schedule': {'key': 'properties.schedule', 'type': 'ScheduleAssociationProperty'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobSchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.job_schedule_id = kwargs.get('job_schedule_id', None) - self.schedule = kwargs.get('schedule', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - - -class JobScheduleCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create job schedule operation. - - All required parameters must be populated in order to send to Azure. - - :param schedule: Required. Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Required. Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets a list of job properties. - :type parameters: dict[str, str] - """ - - _validation = { - 'schedule': {'required': True}, - 'runbook': {'required': True}, - } - - _attribute_map = { - 'schedule': {'key': 'properties.schedule', 'type': 'ScheduleAssociationProperty'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobScheduleCreateParameters, self).__init__(**kwargs) - self.schedule = kwargs['schedule'] - self.runbook = kwargs['runbook'] - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - - -class JobScheduleListResult(msrest.serialization.Model): - """The response model for the list job schedule operation. - - :param value: Gets or sets a list of job schedules. - :type value: list[~azure.mgmt.automation.models.JobSchedule] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class JobStream(msrest.serialization.Model): - """Definition of the job stream. - - :param id: Gets or sets the id of the resource. - :type id: str - :param job_stream_id: Gets or sets the id of the job stream. - :type job_stream_id: str - :param time: Gets or sets the creation time of the job. - :type time: ~datetime.datetime - :param stream_type: Gets or sets the stream type. Possible values include: "Progress", - "Output", "Warning", "Error", "Debug", "Verbose", "Any". - :type stream_type: str or ~azure.mgmt.automation.models.JobStreamType - :param stream_text: Gets or sets the stream text. - :type stream_text: str - :param summary: Gets or sets the summary. - :type summary: str - :param value: Gets or sets the values of the job stream. - :type value: dict[str, object] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'job_stream_id': {'key': 'properties.jobStreamId', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - 'stream_text': {'key': 'properties.streamText', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStream, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.job_stream_id = kwargs.get('job_stream_id', None) - self.time = kwargs.get('time', None) - self.stream_type = kwargs.get('stream_type', None) - self.stream_text = kwargs.get('stream_text', None) - self.summary = kwargs.get('summary', None) - self.value = kwargs.get('value', None) - - -class JobStreamListResult(msrest.serialization.Model): - """The response model for the list job stream operation. - - :param value: A list of job streams. - :type value: list[~azure.mgmt.automation.models.JobStream] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobStream]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStreamListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Key(msrest.serialization.Model): - """Automation key which is used to register a DSC Node. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar key_name: Automation key name. Possible values include: "Primary", "Secondary". - :vartype key_name: str or ~azure.mgmt.automation.models.AutomationKeyName - :ivar permissions: Automation key permissions. Possible values include: "Read", "Full". - :vartype permissions: str or ~azure.mgmt.automation.models.AutomationKeyPermissions - :ivar value: Value of the Automation Key used for registration. - :vartype value: str - """ - - _validation = { - 'key_name': {'readonly': True}, - 'permissions': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'key_name': {'key': 'KeyName', 'type': 'str'}, - 'permissions': {'key': 'Permissions', 'type': 'str'}, - 'value': {'key': 'Value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Key, self).__init__(**kwargs) - self.key_name = None - self.permissions = None - self.value = None - - -class KeyListResult(msrest.serialization.Model): - """KeyListResult. - - :param keys: Lists the automation keys. - :type keys: list[~azure.mgmt.automation.models.Key] - """ - - _attribute_map = { - 'keys': {'key': 'keys', 'type': '[Key]'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyListResult, self).__init__(**kwargs) - self.keys = kwargs.get('keys', None) - - -class LinkedWorkspace(msrest.serialization.Model): - """Definition of the linked workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the linked workspace. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinkedWorkspace, self).__init__(**kwargs) - self.id = None - - -class LinuxProperties(msrest.serialization.Model): - """Linux specific update configuration. - - :param included_package_classifications: Update classifications included in the software update - configuration. Possible values include: "Unclassified", "Critical", "Security", "Other". - :type included_package_classifications: str or ~azure.mgmt.automation.models.LinuxUpdateClasses - :param excluded_package_name_masks: packages excluded from the software update configuration. - :type excluded_package_name_masks: list[str] - :param included_package_name_masks: packages included from the software update configuration. - :type included_package_name_masks: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str - """ - - _attribute_map = { - 'included_package_classifications': {'key': 'includedPackageClassifications', 'type': 'str'}, - 'excluded_package_name_masks': {'key': 'excludedPackageNameMasks', 'type': '[str]'}, - 'included_package_name_masks': {'key': 'includedPackageNameMasks', 'type': '[str]'}, - 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxProperties, self).__init__(**kwargs) - self.included_package_classifications = kwargs.get('included_package_classifications', None) - self.excluded_package_name_masks = kwargs.get('excluded_package_name_masks', None) - self.included_package_name_masks = kwargs.get('included_package_name_masks', None) - self.reboot_setting = kwargs.get('reboot_setting', None) - - -class Module(TrackedResource): - """Definition of the module type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param is_global: Gets or sets the isGlobal flag of the module. - :type is_global: bool - :param version: Gets or sets the version of the module. - :type version: str - :param size_in_bytes: Gets or sets the size in bytes of the module. - :type size_in_bytes: long - :param activity_count: Gets or sets the activity count of the module. - :type activity_count: int - :param provisioning_state: Gets or sets the provisioning state of the module. Possible values - include: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", - "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", - "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", - "Succeeded", "Failed", "Cancelled", "Updating". - :type provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState - :param content_link: Gets or sets the contentLink of the module. - :type content_link: ~azure.mgmt.automation.models.ContentLink - :param error: Gets or sets the error info of the module. - :type error: ~azure.mgmt.automation.models.ModuleErrorInfo - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - :param is_composite: Gets or sets type of module, if its composite or not. - :type is_composite: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'activity_count': {'key': 'properties.activityCount', 'type': 'int'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - 'error': {'key': 'properties.error', 'type': 'ModuleErrorInfo'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_composite': {'key': 'properties.isComposite', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Module, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.is_global = kwargs.get('is_global', None) - self.version = kwargs.get('version', None) - self.size_in_bytes = kwargs.get('size_in_bytes', None) - self.activity_count = kwargs.get('activity_count', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.content_link = kwargs.get('content_link', None) - self.error = kwargs.get('error', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - self.is_composite = kwargs.get('is_composite', None) - - -class ModuleCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update module operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _validation = { - 'content_link': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs['content_link'] - - -class ModuleErrorInfo(msrest.serialization.Model): - """Definition of the module error info type. - - :param code: Gets or sets the error code. - :type code: str - :param message: Gets or sets the error message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleErrorInfo, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ModuleListResult(msrest.serialization.Model): - """The response model for the list module operation. - - :param value: Gets or sets a list of modules. - :type value: list[~azure.mgmt.automation.models.Module] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Module]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ModuleUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update module operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs.get('content_link', None) - - -class NodeCount(msrest.serialization.Model): - """Number of nodes based on the Filter. - - :param name: Gets the name of a count type. - :type name: str - :param properties: - :type properties: ~azure.mgmt.automation.models.NodeCountProperties - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'NodeCountProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCount, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.properties = kwargs.get('properties', None) - - -class NodeCountProperties(msrest.serialization.Model): - """NodeCountProperties. - - :param count: Gets the count for the name. - :type count: int - """ - - _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCountProperties, self).__init__(**kwargs) - self.count = kwargs.get('count', None) - - -class NodeCounts(msrest.serialization.Model): - """Gets the count of nodes by count type. - - :param value: Gets an array of counts. - :type value: list[~azure.mgmt.automation.models.NodeCount] - :param total_count: Gets the total number of records matching countType criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NodeCount]'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCounts, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.total_count = kwargs.get('total_count', None) - - -class NonAzureQueryProperties(msrest.serialization.Model): - """Non Azure query for the update configuration. - - :param function_alias: Log Analytics Saved Search name. - :type function_alias: str - :param workspace_id: Workspace Id for Log Analytics in which the saved Search is resided. - :type workspace_id: str - """ - - _attribute_map = { - 'function_alias': {'key': 'functionAlias', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NonAzureQueryProperties, self).__init__(**kwargs) - self.function_alias = kwargs.get('function_alias', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -class Operation(msrest.serialization.Model): - """Automation REST API operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Provider, Resource and Operation values. - :type display: ~azure.mgmt.automation.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Provider, Resource and Operation values. - - :param provider: Service provider: Microsoft.Automation. - :type provider: str - :param resource: Resource on which the operation is performed: Runbooks, Jobs etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -class OperationListResult(msrest.serialization.Model): - """The response model for the list of Automation operations. - - :param value: List of Automation operations supported by the Automation resource provider. - :type value: list[~azure.mgmt.automation.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ProxyResource(Resource): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class PythonPackageCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update module operation. - - All required parameters must be populated in order to send to Azure. - - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _validation = { - 'content_link': {'required': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(PythonPackageCreateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs['content_link'] - - -class PythonPackageUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update module operation. - - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(PythonPackageUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class RunAsCredentialAssociationProperty(msrest.serialization.Model): - """Definition of RunAs credential to use for hybrid worker. - - :param name: Gets or sets the name of the credential. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunAsCredentialAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class Runbook(TrackedResource): - """Definition of the runbook type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param runbook_type: Gets or sets the type of the runbook. Possible values include: "Script", - "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param state: Gets or sets the state of the runbook. Possible values include: "New", "Edit", - "Published". - :type state: str or ~azure.mgmt.automation.models.RunbookState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the option to log activity trace of the runbook. - :type log_activity_trace: int - :param job_count: Gets or sets the job count of the runbook. - :type job_count: int - :param parameters: Gets or sets the runbook parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :ivar provisioning_state: Gets or sets the provisioning state of the runbook. Default value: - "Succeeded". - :vartype provisioning_state: str - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'runbook_type': {'key': 'properties.runbookType', 'type': 'str'}, - 'publish_content_link': {'key': 'properties.publishContentLink', 'type': 'ContentLink'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - 'job_count': {'key': 'properties.jobCount', 'type': 'int'}, - 'parameters': {'key': 'properties.parameters', 'type': '{RunbookParameter}'}, - 'output_types': {'key': 'properties.outputTypes', 'type': '[str]'}, - 'draft': {'key': 'properties.draft', 'type': 'RunbookDraft'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - provisioning_state = "Succeeded" - - def __init__( - self, - **kwargs - ): - super(Runbook, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.runbook_type = kwargs.get('runbook_type', None) - self.publish_content_link = kwargs.get('publish_content_link', None) - self.state = kwargs.get('state', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - self.job_count = kwargs.get('job_count', None) - self.parameters = kwargs.get('parameters', None) - self.output_types = kwargs.get('output_types', None) - self.draft = kwargs.get('draft', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class RunbookAssociationProperty(msrest.serialization.Model): - """The runbook property associated with the entity. - - :param name: Gets or sets the name of the runbook. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class RunbookCreateOrUpdateDraftParameters(msrest.serialization.Model): - """The parameters supplied to the create or update runbook operation. - - All required parameters must be populated in order to send to Azure. - - :param runbook_content: Required. Content of the Runbook. - :type runbook_content: str - """ - - _validation = { - 'runbook_content': {'required': True}, - } - - _attribute_map = { - 'runbook_content': {'key': 'runbookContent', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateDraftParameters, self).__init__(**kwargs) - self.runbook_content = kwargs['runbook_content'] - - -class RunbookCreateOrUpdateDraftProperties(msrest.serialization.Model): - """The parameters supplied to the create or update draft runbook properties. - - All required parameters must be populated in order to send to Azure. - - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Required. Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _validation = { - 'runbook_type': {'required': True}, - 'draft': {'required': True}, - } - - _attribute_map = { - 'log_verbose': {'key': 'logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'logProgress', 'type': 'bool'}, - 'runbook_type': {'key': 'runbookType', 'type': 'str'}, - 'draft': {'key': 'draft', 'type': 'RunbookDraft'}, - 'description': {'key': 'description', 'type': 'str'}, - 'log_activity_trace': {'key': 'logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateDraftProperties, self).__init__(**kwargs) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.runbook_type = kwargs['runbook_type'] - self.draft = kwargs['draft'] - self.description = kwargs.get('description', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class RunbookCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update runbook operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _validation = { - 'runbook_type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'runbook_type': {'key': 'properties.runbookType', 'type': 'str'}, - 'draft': {'key': 'properties.draft', 'type': 'RunbookDraft'}, - 'publish_content_link': {'key': 'properties.publishContentLink', 'type': 'ContentLink'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.runbook_type = kwargs['runbook_type'] - self.draft = kwargs.get('draft', None) - self.publish_content_link = kwargs.get('publish_content_link', None) - self.description = kwargs.get('description', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class RunbookDraft(msrest.serialization.Model): - """RunbookDraft. - - :param in_edit: Gets or sets whether runbook is in edit mode. - :type in_edit: bool - :param draft_content_link: Gets or sets the draft runbook content link. - :type draft_content_link: ~azure.mgmt.automation.models.ContentLink - :param creation_time: Gets or sets the creation time of the runbook draft. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time of the runbook draft. - :type last_modified_time: ~datetime.datetime - :param parameters: Gets or sets the runbook draft parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] - """ - - _attribute_map = { - 'in_edit': {'key': 'inEdit', 'type': 'bool'}, - 'draft_content_link': {'key': 'draftContentLink', 'type': 'ContentLink'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'parameters', 'type': '{RunbookParameter}'}, - 'output_types': {'key': 'outputTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookDraft, self).__init__(**kwargs) - self.in_edit = kwargs.get('in_edit', None) - self.draft_content_link = kwargs.get('draft_content_link', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.output_types = kwargs.get('output_types', None) - - -class RunbookDraftUndoEditResult(msrest.serialization.Model): - """The response model for the undo edit runbook operation. - - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.automation.models.HttpStatusCode - :param request_id: - :type request_id: str - """ - - _attribute_map = { - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookDraftUndoEditResult, self).__init__(**kwargs) - self.status_code = kwargs.get('status_code', None) - self.request_id = kwargs.get('request_id', None) - - -class RunbookListResult(msrest.serialization.Model): - """The response model for the list runbook operation. - - :param value: Gets or sets a list of runbooks. - :type value: list[~azure.mgmt.automation.models.Runbook] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Runbook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RunbookParameter(msrest.serialization.Model): - """Definition of the runbook parameter type. - - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'int'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookParameter, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.position = kwargs.get('position', None) - self.default_value = kwargs.get('default_value', None) - - -class RunbookUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update runbook operation. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class Schedule(Resource): - """Definition of the schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :ivar start_time_offset_minutes: Gets the start time's offset in minutes. - :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start_time_offset_minutes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'start_time_offset_minutes': {'key': 'properties.startTimeOffsetMinutes', 'type': 'float'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'expiry_time_offset_minutes': {'key': 'properties.expiryTimeOffsetMinutes', 'type': 'float'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'next_run': {'key': 'properties.nextRun', 'type': 'iso-8601'}, - 'next_run_offset_minutes': {'key': 'properties.nextRunOffsetMinutes', 'type': 'float'}, - 'interval': {'key': 'properties.interval', 'type': 'object'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'properties.advancedSchedule', 'type': 'AdvancedSchedule'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Schedule, self).__init__(**kwargs) - self.start_time = kwargs.get('start_time', None) - self.start_time_offset_minutes = None - self.expiry_time = kwargs.get('expiry_time', None) - self.expiry_time_offset_minutes = kwargs.get('expiry_time_offset_minutes', None) - self.is_enabled = kwargs.get('is_enabled', False) - self.next_run = kwargs.get('next_run', None) - self.next_run_offset_minutes = kwargs.get('next_run_offset_minutes', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs.get('frequency', None) - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ScheduleAssociationProperty(msrest.serialization.Model): - """The schedule property associated with the entity. - - :param name: Gets or sets the name of the Schedule. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ScheduleCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update schedule operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param start_time: Required. Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Required. Gets or sets the frequency of the schedule. Possible values - include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the AdvancedSchedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - """ - - _validation = { - 'name': {'required': True}, - 'start_time': {'required': True}, - 'frequency': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'interval': {'key': 'properties.interval', 'type': 'object'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'properties.advancedSchedule', 'type': 'AdvancedSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.description = kwargs.get('description', None) - self.start_time = kwargs['start_time'] - self.expiry_time = kwargs.get('expiry_time', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs['frequency'] - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - - -class ScheduleListResult(msrest.serialization.Model): - """The response model for the list schedule operation. - - :param value: Gets or sets a list of schedules. - :type value: list[~azure.mgmt.automation.models.Schedule] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Schedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ScheduleUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update schedule operation. - - :param name: Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.is_enabled = kwargs.get('is_enabled', None) - - -class Sku(msrest.serialization.Model): - """The account SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the SKU name of the account. Possible values include: - "Free", "Basic". - :type name: str or ~azure.mgmt.automation.models.SkuNameEnum - :param family: Gets or sets the SKU family. - :type family: str - :param capacity: Gets or sets the SKU capacity. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.family = kwargs.get('family', None) - self.capacity = kwargs.get('capacity', None) - - -class SoftwareUpdateConfiguration(msrest.serialization.Model): - """Software update configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. - :vartype name: str - :ivar id: Resource Id. - :vartype id: str - :ivar type: Resource type. - :vartype type: str - :param update_configuration: Required. update specific properties for the Software update - configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param schedule_info: Required. Schedule information for the Software update configuration. - :type schedule_info: ~azure.mgmt.automation.models.SUCScheduleProperties - :ivar provisioning_state: Provisioning state for the software update configuration, which only - appears in the response. - :vartype provisioning_state: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: CreatedBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: LastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param tasks: Tasks information for the Software update configuration. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'update_configuration': {'required': True}, - 'schedule_info': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'update_configuration': {'key': 'properties.updateConfiguration', 'type': 'UpdateConfiguration'}, - 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'SUCScheduleProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponse'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationTasks'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfiguration, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - self.update_configuration = kwargs['update_configuration'] - self.schedule_info = kwargs['schedule_info'] - self.provisioning_state = None - self.error = kwargs.get('error', None) - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.tasks = kwargs.get('tasks', None) - - -class SoftwareUpdateConfigurationCollectionItem(msrest.serialization.Model): - """Software update configuration collection item properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration. - :vartype name: str - :ivar id: Resource Id of the software update configuration. - :vartype id: str - :param update_configuration: Update specific properties of the software update configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param tasks: Pre and Post Tasks defined. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks - :param frequency: execution frequency of the schedule associated with the software update - configuration. Possible values include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param start_time: the start time of the update. - :type start_time: ~datetime.datetime - :ivar creation_time: Creation time of the software update configuration, which only appears in - the response. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Last time software update configuration was modified, which only - appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar provisioning_state: Provisioning state for the software update configuration, which only - appears in the response. - :vartype provisioning_state: str - :param next_run: ext run time of the update. - :type next_run: ~datetime.datetime - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'update_configuration': {'key': 'properties.updateConfiguration', 'type': 'UpdateConfiguration'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationTasks'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'next_run': {'key': 'properties.nextRun', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationCollectionItem, self).__init__(**kwargs) - self.name = None - self.id = None - self.update_configuration = kwargs.get('update_configuration', None) - self.tasks = kwargs.get('tasks', None) - self.frequency = kwargs.get('frequency', None) - self.start_time = kwargs.get('start_time', None) - self.creation_time = None - self.last_modified_time = None - self.provisioning_state = None - self.next_run = kwargs.get('next_run', None) - - -class SoftwareUpdateConfigurationListResult(msrest.serialization.Model): - """result of listing all software update configuration. - - :param value: outer object returned when listing all software update configurations. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationCollectionItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): - """Software update configuration machine run model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration machine run. - :vartype name: str - :ivar id: Resource Id of the software update configuration machine run. - :vartype id: str - :ivar target_computer: name of the updated computer. - :vartype target_computer: str - :ivar target_computer_type: type of the updated computer. - :vartype target_computer_type: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: - ~azure.mgmt.automation.models.UpdateConfigurationNavigation - :ivar status: Status of the software update configuration machine run. - :vartype status: str - :ivar os_type: Operating system target of the software update configuration triggered this run. - :vartype os_type: str - :ivar correlation_id: correlation id of the software update configuration machine run. - :vartype correlation_id: str - :ivar source_computer_id: source computer id of the software update configuration machine run. - :vartype source_computer_id: str - :ivar start_time: Start time of the software update configuration machine run. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the software update configuration machine run. - :vartype end_time: ~datetime.datetime - :ivar configured_duration: configured duration for the software update configuration run. - :vartype configured_duration: str - :param job: Job associated with the software update configuration machine run. - :type job: ~azure.mgmt.automation.models.JobNavigation - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: createdBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: lastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'target_computer': {'readonly': True}, - 'target_computer_type': {'readonly': True}, - 'status': {'readonly': True}, - 'os_type': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'source_computer_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'configured_duration': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'target_computer': {'key': 'properties.targetComputer', 'type': 'str'}, - 'target_computer_type': {'key': 'properties.targetComputerType', 'type': 'str'}, - 'software_update_configuration': {'key': 'properties.softwareUpdateConfiguration', 'type': 'UpdateConfigurationNavigation'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'correlation_id': {'key': 'properties.correlationId', 'type': 'str'}, - 'source_computer_id': {'key': 'properties.sourceComputerId', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'configured_duration': {'key': 'properties.configuredDuration', 'type': 'str'}, - 'job': {'key': 'properties.job', 'type': 'JobNavigation'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationMachineRun, self).__init__(**kwargs) - self.name = None - self.id = None - self.target_computer = None - self.target_computer_type = None - self.software_update_configuration = kwargs.get('software_update_configuration', None) - self.status = None - self.os_type = None - self.correlation_id = None - self.source_computer_id = None - self.start_time = None - self.end_time = None - self.configured_duration = None - self.job = kwargs.get('job', None) - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.error = kwargs.get('error', None) - - -class SoftwareUpdateConfigurationMachineRunListResult(msrest.serialization.Model): - """result of listing all software update configuration machine runs. - - :param value: outer object returned when listing all software update configuration machine - runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun] - :param next_link: link to next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationMachineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationMachineRunListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SoftwareUpdateConfigurationRun(msrest.serialization.Model): - """Software update configuration Run properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration run. - :vartype name: str - :ivar id: Resource Id of the software update configuration run. - :vartype id: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: - ~azure.mgmt.automation.models.UpdateConfigurationNavigation - :ivar status: Status of the software update configuration run. - :vartype status: str - :ivar configured_duration: Configured duration for the software update configuration run. - :vartype configured_duration: str - :ivar os_type: Operating system target of the software update configuration triggered this run. - :vartype os_type: str - :ivar start_time: Start time of the software update configuration run. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the software update configuration run. - :vartype end_time: ~datetime.datetime - :ivar computer_count: Number of computers in the software update configuration run. - :vartype computer_count: int - :ivar failed_count: Number of computers with failed status. - :vartype failed_count: int - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: CreatedBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: LastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param tasks: Software update configuration tasks triggered in this run. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTasks - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'status': {'readonly': True}, - 'configured_duration': {'readonly': True}, - 'os_type': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'computer_count': {'readonly': True}, - 'failed_count': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'software_update_configuration': {'key': 'properties.softwareUpdateConfiguration', 'type': 'UpdateConfigurationNavigation'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'configured_duration': {'key': 'properties.configuredDuration', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'computer_count': {'key': 'properties.computerCount', 'type': 'int'}, - 'failed_count': {'key': 'properties.failedCount', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationRunTasks'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRun, self).__init__(**kwargs) - self.name = None - self.id = None - self.software_update_configuration = kwargs.get('software_update_configuration', None) - self.status = None - self.configured_duration = None - self.os_type = None - self.start_time = None - self.end_time = None - self.computer_count = None - self.failed_count = None - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.tasks = kwargs.get('tasks', None) - - -class SoftwareUpdateConfigurationRunListResult(msrest.serialization.Model): - """result of listing all software update configuration runs. - - :param value: outer object returned when listing all software update configuration runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] - :param next_link: link to next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SoftwareUpdateConfigurationRunTaskProperties(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param status: The status of the task. - :type status: str - :param source: The name of the source of the task. - :type source: str - :param job_id: The job id of the task. - :type job_id: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'job_id': {'key': 'jobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunTaskProperties, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.source = kwargs.get('source', None) - self.job_id = kwargs.get('job_id', None) - - -class SoftwareUpdateConfigurationRunTasks(msrest.serialization.Model): - """Software update configuration run tasks model. - - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties - """ - - _attribute_map = { - 'pre_task': {'key': 'preTask', 'type': 'SoftwareUpdateConfigurationRunTaskProperties'}, - 'post_task': {'key': 'postTask', 'type': 'SoftwareUpdateConfigurationRunTaskProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunTasks, self).__init__(**kwargs) - self.pre_task = kwargs.get('pre_task', None) - self.post_task = kwargs.get('post_task', None) - - -class SoftwareUpdateConfigurationTasks(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.TaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.TaskProperties - """ - - _attribute_map = { - 'pre_task': {'key': 'preTask', 'type': 'TaskProperties'}, - 'post_task': {'key': 'postTask', 'type': 'TaskProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationTasks, self).__init__(**kwargs) - self.pre_task = kwargs.get('pre_task', None) - self.post_task = kwargs.get('post_task', None) - - -class SourceControl(Resource): - """Definition of the source control. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for - VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub. Possible values - include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param description: The description. - :type description: str - :param creation_time: The creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: The last modified time. - :type last_modified_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'repo_url': {'key': 'properties.repoUrl', 'type': 'str'}, - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControl, self).__init__(**kwargs) - self.repo_url = kwargs.get('repo_url', None) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.source_type = kwargs.get('source_type', None) - self.description = kwargs.get('description', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - - -class SourceControlCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update source control operation. - - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for - VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto async of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. - Possible values include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str - """ - - _validation = { - 'repo_url': {'max_length': 2000, 'min_length': 0}, - 'branch': {'max_length': 255, 'min_length': 0}, - 'folder_path': {'max_length': 255, 'min_length': 0}, - 'description': {'max_length': 512, 'min_length': 0}, - } - - _attribute_map = { - 'repo_url': {'key': 'properties.repoUrl', 'type': 'str'}, - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'SourceControlSecurityTokenProperties'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlCreateOrUpdateParameters, self).__init__(**kwargs) - self.repo_url = kwargs.get('repo_url', None) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.source_type = kwargs.get('source_type', None) - self.security_token = kwargs.get('security_token', None) - self.description = kwargs.get('description', None) - - -class SourceControlListResult(msrest.serialization.Model): - """The response model for the list source controls operation. - - :param value: The list of source controls. - :type value: list[~azure.mgmt.automation.models.SourceControl] - :param next_link: The next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControl]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SourceControlSecurityTokenProperties(msrest.serialization.Model): - """SourceControlSecurityTokenProperties. - - :param access_token: The access token. - :type access_token: str - :param refresh_token: The refresh token. - :type refresh_token: str - :param token_type: The token type. Must be either PersonalAccessToken or Oauth. Possible values - include: "PersonalAccessToken", "Oauth". - :type token_type: str or ~azure.mgmt.automation.models.TokenType - """ - - _validation = { - 'access_token': {'max_length': 1024, 'min_length': 0}, - 'refresh_token': {'max_length': 1024, 'min_length': 0}, - } - - _attribute_map = { - 'access_token': {'key': 'accessToken', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'token_type': {'key': 'tokenType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSecurityTokenProperties, self).__init__(**kwargs) - self.access_token = kwargs.get('access_token', None) - self.refresh_token = kwargs.get('refresh_token', None) - self.token_type = kwargs.get('token_type', None) - - -class SourceControlSyncJob(msrest.serialization.Model): - """Definition of the source control sync job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_id': {'key': 'properties.sourceControlSyncJobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'sync_type': {'key': 'properties.syncType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJob, self).__init__(**kwargs) - self.name = None - self.type = None - self.id = None - self.source_control_sync_job_id = kwargs.get('source_control_sync_job_id', None) - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.start_time = None - self.end_time = None - self.sync_type = kwargs.get('sync_type', None) - - -class SourceControlSyncJobById(msrest.serialization.Model): - """Definition of the source control sync job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: The id of the job. - :type id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType - :param exception: The exceptions that occurred while running the sync job. - :type exception: str - """ - - _validation = { - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_id': {'key': 'properties.sourceControlSyncJobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'sync_type': {'key': 'properties.syncType', 'type': 'str'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobById, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.source_control_sync_job_id = kwargs.get('source_control_sync_job_id', None) - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.start_time = None - self.end_time = None - self.sync_type = kwargs.get('sync_type', None) - self.exception = kwargs.get('exception', None) - - -class SourceControlSyncJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create source control sync job operation. - - All required parameters must be populated in order to send to Azure. - - :param commit_id: Required. The commit id of the source control sync job. If not syncing to a - commitId, enter an empty string. - :type commit_id: str - """ - - _validation = { - 'commit_id': {'required': True}, - } - - _attribute_map = { - 'commit_id': {'key': 'properties.commitId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobCreateParameters, self).__init__(**kwargs) - self.commit_id = kwargs['commit_id'] - - -class SourceControlSyncJobListResult(msrest.serialization.Model): - """The response model for the list source control sync jobs operation. - - :param value: The list of source control sync jobs. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJob] - :param next_link: The next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlSyncJob]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SourceControlSyncJobStream(msrest.serialization.Model): - """Definition of the source control sync job stream. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str - :ivar time: The time of the sync job stream. - :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType - """ - - _validation = { - 'id': {'readonly': True}, - 'time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_stream_id': {'key': 'properties.sourceControlSyncJobStreamId', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStream, self).__init__(**kwargs) - self.id = None - self.source_control_sync_job_stream_id = kwargs.get('source_control_sync_job_stream_id', None) - self.summary = kwargs.get('summary', None) - self.time = None - self.stream_type = kwargs.get('stream_type', None) - - -class SourceControlSyncJobStreamById(msrest.serialization.Model): - """Definition of the source control sync job stream by id. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str - :ivar time: The time of the sync job stream. - :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType - :param stream_text: The text of the sync job stream. - :type stream_text: str - :param value: The values of the job stream. - :type value: dict[str, object] - """ - - _validation = { - 'id': {'readonly': True}, - 'time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_stream_id': {'key': 'properties.sourceControlSyncJobStreamId', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - 'stream_text': {'key': 'properties.streamText', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStreamById, self).__init__(**kwargs) - self.id = None - self.source_control_sync_job_stream_id = kwargs.get('source_control_sync_job_stream_id', None) - self.summary = kwargs.get('summary', None) - self.time = None - self.stream_type = kwargs.get('stream_type', None) - self.stream_text = kwargs.get('stream_text', None) - self.value = kwargs.get('value', None) - - -class SourceControlSyncJobStreamsListBySyncJob(msrest.serialization.Model): - """The response model for the list source control sync job streams operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of source control sync job streams. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlSyncJobStream]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStreamsListBySyncJob, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SourceControlUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update source control operation. - - :param branch: The repo branch of the source control. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str - """ - - _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'SourceControlSecurityTokenProperties'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlUpdateParameters, self).__init__(**kwargs) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.security_token = kwargs.get('security_token', None) - self.description = kwargs.get('description', None) - - -class Statistics(msrest.serialization.Model): - """Definition of the statistic. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar counter_property: Gets the property value of the statistic. - :vartype counter_property: str - :ivar counter_value: Gets the value of the statistic. - :vartype counter_value: long - :ivar start_time: Gets the startTime of the statistic. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets the endTime of the statistic. - :vartype end_time: ~datetime.datetime - :ivar id: Gets the id. - :vartype id: str - """ - - _validation = { - 'counter_property': {'readonly': True}, - 'counter_value': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'id': {'readonly': True}, - } - - _attribute_map = { - 'counter_property': {'key': 'counterProperty', 'type': 'str'}, - 'counter_value': {'key': 'counterValue', 'type': 'long'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Statistics, self).__init__(**kwargs) - self.counter_property = None - self.counter_value = None - self.start_time = None - self.end_time = None - self.id = None - - -class StatisticsListResult(msrest.serialization.Model): - """The response model for the list statistics operation. - - :param value: Gets or sets a list of statistics. - :type value: list[~azure.mgmt.automation.models.Statistics] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Statistics]'}, - } - - def __init__( - self, - **kwargs - ): - super(StatisticsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SUCScheduleProperties(msrest.serialization.Model): - """Definition of schedule parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :ivar start_time_offset_minutes: Gets the start time's offset in minutes. - :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: long - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'start_time_offset_minutes': {'readonly': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'start_time_offset_minutes': {'key': 'startTimeOffsetMinutes', 'type': 'float'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'expiry_time_offset_minutes': {'key': 'expiryTimeOffsetMinutes', 'type': 'float'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'next_run': {'key': 'nextRun', 'type': 'iso-8601'}, - 'next_run_offset_minutes': {'key': 'nextRunOffsetMinutes', 'type': 'float'}, - 'interval': {'key': 'interval', 'type': 'long'}, - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'advancedSchedule', 'type': 'AdvancedSchedule'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SUCScheduleProperties, self).__init__(**kwargs) - self.start_time = kwargs.get('start_time', None) - self.start_time_offset_minutes = None - self.expiry_time = kwargs.get('expiry_time', None) - self.expiry_time_offset_minutes = kwargs.get('expiry_time_offset_minutes', None) - self.is_enabled = kwargs.get('is_enabled', False) - self.next_run = kwargs.get('next_run', None) - self.next_run_offset_minutes = kwargs.get('next_run_offset_minutes', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs.get('frequency', None) - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class TagSettingsProperties(msrest.serialization.Model): - """Tag filter information for the VM. - - :param tags: A set of tags. Dictionary of tags with its list of values. - :type tags: dict[str, list[str]] - :param filter_operator: Filter VMs by Any or All specified tags. Possible values include: - "All", "Any". - :type filter_operator: str or ~azure.mgmt.automation.models.TagOperators - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{[str]}'}, - 'filter_operator': {'key': 'filterOperator', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagSettingsProperties, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.filter_operator = kwargs.get('filter_operator', None) - - -class TargetProperties(msrest.serialization.Model): - """Group specific to the update configuration. - - :param azure_queries: List of Azure queries in the software update configuration. - :type azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] - :param non_azure_queries: List of non Azure queries in the software update configuration. - :type non_azure_queries: list[~azure.mgmt.automation.models.NonAzureQueryProperties] - """ - - _attribute_map = { - 'azure_queries': {'key': 'azureQueries', 'type': '[AzureQueryProperties]'}, - 'non_azure_queries': {'key': 'nonAzureQueries', 'type': '[NonAzureQueryProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetProperties, self).__init__(**kwargs) - self.azure_queries = kwargs.get('azure_queries', None) - self.non_azure_queries = kwargs.get('non_azure_queries', None) - - -class TaskProperties(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param parameters: Gets or sets the parameters of the task. - :type parameters: dict[str, str] - :param source: Gets or sets the name of the runbook. - :type source: str - """ - - _attribute_map = { - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'source': {'key': 'source', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TaskProperties, self).__init__(**kwargs) - self.parameters = kwargs.get('parameters', None) - self.source = kwargs.get('source', None) - - -class TestJob(msrest.serialization.Model): - """Definition of the test job. - - :param creation_time: Gets or sets the creation time of the test job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the test job. - :type status: str - :param status_details: Gets or sets the status details of the test job. - :type status_details: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param start_time: Gets or sets the start time of the test job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the test job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the test job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the test job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the test job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param log_activity_trace: The activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'status_details': {'key': 'statusDetails', 'type': 'str'}, - 'run_on': {'key': 'runOn', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'exception', 'type': 'str'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'log_activity_trace': {'key': 'logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(TestJob, self).__init__(**kwargs) - self.creation_time = kwargs.get('creation_time', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.run_on = kwargs.get('run_on', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.exception = kwargs.get('exception', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_status_modified_time = kwargs.get('last_status_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class TestJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create test job operation. - - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - """ - - _attribute_map = { - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'run_on': {'key': 'runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TestJobCreateParameters, self).__init__(**kwargs) - self.parameters = kwargs.get('parameters', None) - self.run_on = kwargs.get('run_on', None) - - -class TypeField(msrest.serialization.Model): - """Information about a field of a type. - - :param name: Gets or sets the name of the field. - :type name: str - :param type: Gets or sets the type of the field. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TypeField, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class TypeFieldListResult(msrest.serialization.Model): - """The response model for the list fields operation. - - :param value: Gets or sets a list of fields. - :type value: list[~azure.mgmt.automation.models.TypeField] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TypeField]'}, - } - - def __init__( - self, - **kwargs - ): - super(TypeFieldListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UpdateConfiguration(msrest.serialization.Model): - """Update specific properties of the software update configuration. - - All required parameters must be populated in order to send to Azure. - - :param operating_system: Required. operating system of target machines. Possible values - include: "Windows", "Linux". - :type operating_system: str or ~azure.mgmt.automation.models.OperatingSystemType - :param windows: Windows specific update configuration. - :type windows: ~azure.mgmt.automation.models.WindowsProperties - :param linux: Linux specific update configuration. - :type linux: ~azure.mgmt.automation.models.LinuxProperties - :param duration: Maximum time allowed for the software update configuration run. Duration needs - to be specified using the format PT[n]H[n]M[n]S as per ISO8601. - :type duration: ~datetime.timedelta - :param azure_virtual_machines: List of azure resource Ids for azure virtual machines targeted - by the software update configuration. - :type azure_virtual_machines: list[str] - :param non_azure_computer_names: List of names of non-azure machines targeted by the software - update configuration. - :type non_azure_computer_names: list[str] - :param targets: Group targets for the software update configuration. - :type targets: ~azure.mgmt.automation.models.TargetProperties - """ - - _validation = { - 'operating_system': {'required': True}, - } - - _attribute_map = { - 'operating_system': {'key': 'operatingSystem', 'type': 'str'}, - 'windows': {'key': 'windows', 'type': 'WindowsProperties'}, - 'linux': {'key': 'linux', 'type': 'LinuxProperties'}, - 'duration': {'key': 'duration', 'type': 'duration'}, - 'azure_virtual_machines': {'key': 'azureVirtualMachines', 'type': '[str]'}, - 'non_azure_computer_names': {'key': 'nonAzureComputerNames', 'type': '[str]'}, - 'targets': {'key': 'targets', 'type': 'TargetProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateConfiguration, self).__init__(**kwargs) - self.operating_system = kwargs['operating_system'] - self.windows = kwargs.get('windows', None) - self.linux = kwargs.get('linux', None) - self.duration = kwargs.get('duration', None) - self.azure_virtual_machines = kwargs.get('azure_virtual_machines', None) - self.non_azure_computer_names = kwargs.get('non_azure_computer_names', None) - self.targets = kwargs.get('targets', None) - - -class UpdateConfigurationNavigation(msrest.serialization.Model): - """Software update configuration Run Navigation model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration triggered the software update - configuration run. - :vartype name: str - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateConfigurationNavigation, self).__init__(**kwargs) - self.name = None - - -class Usage(msrest.serialization.Model): - """Definition of Usage. - - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the usage counter name. - :type name: ~azure.mgmt.automation.models.UsageCounterName - :param unit: Gets or sets the usage unit name. - :type unit: str - :param current_value: Gets or sets the current usage value. - :type current_value: float - :param limit: Gets or sets max limit. -1 for unlimited. - :type limit: long - :param throttle_status: Gets or sets the throttle status. - :type throttle_status: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'UsageCounterName'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'throttle_status': {'key': 'throttleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Usage, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.throttle_status = kwargs.get('throttle_status', None) - - -class UsageCounterName(msrest.serialization.Model): - """Definition of usage counter name. - - :param value: Gets or sets the usage counter name. - :type value: str - :param localized_value: Gets or sets the localized usage counter name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageCounterName, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class UsageListResult(msrest.serialization.Model): - """The response model for the get usage operation. - - :param value: Gets or sets usage. - :type value: list[~azure.mgmt.automation.models.Usage] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Variable(Resource): - """Definition of the variable. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param value: Gets or sets the value of the variable. - :type value: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'is_encrypted': {'key': 'properties.isEncrypted', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Variable, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.is_encrypted = kwargs.get('is_encrypted', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class VariableCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update variable operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_encrypted': {'key': 'properties.isEncrypted', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.value = kwargs.get('value', None) - self.description = kwargs.get('description', None) - self.is_encrypted = kwargs.get('is_encrypted', None) - - -class VariableListResult(msrest.serialization.Model): - """The response model for the list variables operation. - - :param value: Gets or sets a list of variables. - :type value: list[~azure.mgmt.automation.models.Variable] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Variable]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class VariableUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update variable operation. - - :param name: Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - self.description = kwargs.get('description', None) - - -class Watcher(Resource): - """Definition of the watcher type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The geo-location where the resource lives. - :type location: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is - invoked. - :type execution_frequency_in_seconds: long - :param script_name: Gets or sets the name of the script the watcher is attached to, i.e. the - name of an existing runbook. - :type script_name: str - :param script_parameters: Gets or sets the parameters of the script. - :type script_parameters: dict[str, str] - :param script_run_on: Gets or sets the name of the hybrid worker group the watcher will run on. - :type script_run_on: str - :ivar status: Gets the current status of the watcher. - :vartype status: str - :ivar creation_time: Gets or sets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets or sets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: Details of the user who last modified the watcher. - :vartype last_modified_by: str - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'execution_frequency_in_seconds': {'key': 'properties.executionFrequencyInSeconds', 'type': 'long'}, - 'script_name': {'key': 'properties.scriptName', 'type': 'str'}, - 'script_parameters': {'key': 'properties.scriptParameters', 'type': '{str}'}, - 'script_run_on': {'key': 'properties.scriptRunOn', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Watcher, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - self.execution_frequency_in_seconds = kwargs.get('execution_frequency_in_seconds', None) - self.script_name = kwargs.get('script_name', None) - self.script_parameters = kwargs.get('script_parameters', None) - self.script_run_on = kwargs.get('script_run_on', None) - self.status = None - self.creation_time = None - self.last_modified_time = None - self.last_modified_by = None - self.description = kwargs.get('description', None) - - -class WatcherListResult(msrest.serialization.Model): - """The response model for the list watcher operation. - - :param value: Gets or sets a list of watchers. - :type value: list[~azure.mgmt.automation.models.Watcher] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Watcher]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WatcherListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class WatcherUpdateParameters(msrest.serialization.Model): - """WatcherUpdateParameters. - - :param name: Gets or sets the name of the resource. - :type name: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is - invoked. - :type execution_frequency_in_seconds: long - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'execution_frequency_in_seconds': {'key': 'properties.executionFrequencyInSeconds', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WatcherUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.execution_frequency_in_seconds = kwargs.get('execution_frequency_in_seconds', None) - - -class Webhook(Resource): - """Definition of the webhook type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param is_enabled: Gets or sets the value of the enabled flag of the webhook. - :type is_enabled: bool - :param uri: Gets or sets the webhook uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param last_invoked_time: Gets or sets the last invoked time. - :type last_invoked_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job that is created when the webhook - calls the runbook it is associated with. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook the webhook is associated with. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param last_modified_by: Details of the user who last modified the Webhook. - :type last_modified_by: str - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'last_invoked_time': {'key': 'properties.lastInvokedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Webhook, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', False) - self.uri = kwargs.get('uri', None) - self.expiry_time = kwargs.get('expiry_time', None) - self.last_invoked_time = kwargs.get('last_invoked_time', None) - self.parameters = kwargs.get('parameters', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.description = kwargs.get('description', None) - - -class WebhookCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update webhook operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param uri: Gets or sets the uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.is_enabled = kwargs.get('is_enabled', None) - self.uri = kwargs.get('uri', None) - self.expiry_time = kwargs.get('expiry_time', None) - self.parameters = kwargs.get('parameters', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - - -class WebhookListResult(msrest.serialization.Model): - """The response model for the list webhook operation. - - :param value: Gets or sets a list of webhooks. - :type value: list[~azure.mgmt.automation.models.Webhook] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class WebhookUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update webhook operation. - - :param name: Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param description: Gets or sets the description of the webhook. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class WindowsProperties(msrest.serialization.Model): - """Windows specific update configuration. - - :param included_update_classifications: Update classification included in the software update - configuration. A comma separated string with required values. Possible values include: - "Unclassified", "Critical", "Security", "UpdateRollup", "FeaturePack", "ServicePack", - "Definition", "Tools", "Updates". - :type included_update_classifications: str or - ~azure.mgmt.automation.models.WindowsUpdateClasses - :param excluded_kb_numbers: KB numbers excluded from the software update configuration. - :type excluded_kb_numbers: list[str] - :param included_kb_numbers: KB numbers included from the software update configuration. - :type included_kb_numbers: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str - """ - - _attribute_map = { - 'included_update_classifications': {'key': 'includedUpdateClassifications', 'type': 'str'}, - 'excluded_kb_numbers': {'key': 'excludedKbNumbers', 'type': '[str]'}, - 'included_kb_numbers': {'key': 'includedKbNumbers', 'type': '[str]'}, - 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsProperties, self).__init__(**kwargs) - self.included_update_classifications = kwargs.get('included_update_classifications', None) - self.excluded_kb_numbers = kwargs.get('excluded_kb_numbers', None) - self.included_kb_numbers = kwargs.get('included_kb_numbers', None) - self.reboot_setting = kwargs.get('reboot_setting', None) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py index 7fbb522912f4..3469b23ced01 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._automation_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Activity(msrest.serialization.Model): @@ -20,22 +22,22 @@ class Activity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Gets or sets the id of the resource. - :type id: str + :ivar id: Gets or sets the id of the resource. + :vartype id: str :ivar name: Gets the name of the activity. :vartype name: str - :param definition: Gets or sets the user name of the activity. - :type definition: str - :param parameter_sets: Gets or sets the parameter sets of the activity. - :type parameter_sets: list[~azure.mgmt.automation.models.ActivityParameterSet] - :param output_types: Gets or sets the output types of the activity. - :type output_types: list[~azure.mgmt.automation.models.ActivityOutputType] - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar definition: Gets or sets the user name of the activity. + :vartype definition: str + :ivar parameter_sets: Gets or sets the parameter sets of the activity. + :vartype parameter_sets: list[~azure.mgmt.automation.models.ActivityParameterSet] + :ivar output_types: Gets or sets the output types of the activity. + :vartype output_types: list[~azure.mgmt.automation.models.ActivityOutputType] + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -58,13 +60,29 @@ def __init__( *, id: Optional[str] = None, definition: Optional[str] = None, - parameter_sets: Optional[List["ActivityParameterSet"]] = None, - output_types: Optional[List["ActivityOutputType"]] = None, + parameter_sets: Optional[List["_models.ActivityParameterSet"]] = None, + output_types: Optional[List["_models.ActivityOutputType"]] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword id: Gets or sets the id of the resource. + :paramtype id: str + :keyword definition: Gets or sets the user name of the activity. + :paramtype definition: str + :keyword parameter_sets: Gets or sets the parameter sets of the activity. + :paramtype parameter_sets: list[~azure.mgmt.automation.models.ActivityParameterSet] + :keyword output_types: Gets or sets the output types of the activity. + :paramtype output_types: list[~azure.mgmt.automation.models.ActivityOutputType] + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Activity, self).__init__(**kwargs) self.id = id self.name = None @@ -79,10 +97,10 @@ def __init__( class ActivityListResult(msrest.serialization.Model): """The response model for the list activity operation. - :param value: Gets or sets a list of activities. - :type value: list[~azure.mgmt.automation.models.Activity] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of activities. + :vartype value: list[~azure.mgmt.automation.models.Activity] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -93,10 +111,16 @@ class ActivityListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Activity"]] = None, + value: Optional[List["_models.Activity"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of activities. + :paramtype value: list[~azure.mgmt.automation.models.Activity] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(ActivityListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -105,10 +129,10 @@ def __init__( class ActivityOutputType(msrest.serialization.Model): """Definition of the activity output type. - :param name: Gets or sets the name of the activity output type. - :type name: str - :param type: Gets or sets the type of the activity output type. - :type type: str + :ivar name: Gets or sets the name of the activity output type. + :vartype name: str + :ivar type: Gets or sets the type of the activity output type. + :vartype type: str """ _attribute_map = { @@ -123,6 +147,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the activity output type. + :paramtype name: str + :keyword type: Gets or sets the type of the activity output type. + :paramtype type: str + """ super(ActivityOutputType, self).__init__(**kwargs) self.name = name self.type = type @@ -131,37 +161,36 @@ def __init__( class ActivityParameter(msrest.serialization.Model): """Definition of the activity parameter. - :param name: Gets or sets the name of the activity parameter. - :type name: str - :param type: Gets or sets the type of the activity parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value that indicates true if the parameter is + :ivar name: Gets or sets the name of the activity parameter. + :vartype name: str + :ivar type: Gets or sets the type of the activity parameter. + :vartype type: str + :ivar is_mandatory: Gets or sets a Boolean value that indicates true if the parameter is required. If the value is false, the parameter is optional. - :type is_mandatory: bool - :param is_dynamic: Gets or sets a Boolean value that indicates true if the parameter is - dynamic. - :type is_dynamic: bool - :param position: Gets or sets the position of the activity parameter. - :type position: long - :param value_from_pipeline: Gets or sets a Boolean value that indicates true if the parameter + :vartype is_mandatory: bool + :ivar is_dynamic: Gets or sets a Boolean value that indicates true if the parameter is dynamic. + :vartype is_dynamic: bool + :ivar position: Gets or sets the position of the activity parameter. + :vartype position: long + :ivar value_from_pipeline: Gets or sets a Boolean value that indicates true if the parameter can take values from the incoming pipeline objects. This setting is used if the cmdlet must access the complete input object. false indicates that the parameter cannot take values from the complete input object. - :type value_from_pipeline: bool - :param value_from_pipeline_by_property_name: Gets or sets a Boolean value that indicates true - if the parameter can be filled from a property of the incoming pipeline object that has the - same name as this parameter. false indicates that the parameter cannot be filled from the - incoming pipeline object property with the same name. - :type value_from_pipeline_by_property_name: bool - :param value_from_remaining_arguments: Gets or sets a Boolean value that indicates true if the + :vartype value_from_pipeline: bool + :ivar value_from_pipeline_by_property_name: Gets or sets a Boolean value that indicates true if + the parameter can be filled from a property of the incoming pipeline object that has the same + name as this parameter. false indicates that the parameter cannot be filled from the incoming + pipeline object property with the same name. + :vartype value_from_pipeline_by_property_name: bool + :ivar value_from_remaining_arguments: Gets or sets a Boolean value that indicates true if the cmdlet parameter accepts all the remaining command-line arguments that are associated with this parameter in the form of an array. false if the cmdlet parameter does not accept all the remaining argument values. - :type value_from_remaining_arguments: bool - :param description: Gets or sets the description of the activity parameter. - :type description: str - :param validation_set: Gets or sets the validation set of activity parameter. - :type validation_set: list[~azure.mgmt.automation.models.ActivityParameterValidationSet] + :vartype value_from_remaining_arguments: bool + :ivar description: Gets or sets the description of the activity parameter. + :vartype description: str + :ivar validation_set: Gets or sets the validation set of activity parameter. + :vartype validation_set: list[~azure.mgmt.automation.models.ActivityParameterValidationSet] """ _attribute_map = { @@ -189,9 +218,42 @@ def __init__( value_from_pipeline_by_property_name: Optional[bool] = None, value_from_remaining_arguments: Optional[bool] = None, description: Optional[str] = None, - validation_set: Optional[List["ActivityParameterValidationSet"]] = None, - **kwargs - ): + validation_set: Optional[List["_models.ActivityParameterValidationSet"]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the activity parameter. + :paramtype name: str + :keyword type: Gets or sets the type of the activity parameter. + :paramtype type: str + :keyword is_mandatory: Gets or sets a Boolean value that indicates true if the parameter is + required. If the value is false, the parameter is optional. + :paramtype is_mandatory: bool + :keyword is_dynamic: Gets or sets a Boolean value that indicates true if the parameter is + dynamic. + :paramtype is_dynamic: bool + :keyword position: Gets or sets the position of the activity parameter. + :paramtype position: long + :keyword value_from_pipeline: Gets or sets a Boolean value that indicates true if the parameter + can take values from the incoming pipeline objects. This setting is used if the cmdlet must + access the complete input object. false indicates that the parameter cannot take values from + the complete input object. + :paramtype value_from_pipeline: bool + :keyword value_from_pipeline_by_property_name: Gets or sets a Boolean value that indicates true + if the parameter can be filled from a property of the incoming pipeline object that has the + same name as this parameter. false indicates that the parameter cannot be filled from the + incoming pipeline object property with the same name. + :paramtype value_from_pipeline_by_property_name: bool + :keyword value_from_remaining_arguments: Gets or sets a Boolean value that indicates true if + the cmdlet parameter accepts all the remaining command-line arguments that are associated with + this parameter in the form of an array. false if the cmdlet parameter does not accept all the + remaining argument values. + :paramtype value_from_remaining_arguments: bool + :keyword description: Gets or sets the description of the activity parameter. + :paramtype description: str + :keyword validation_set: Gets or sets the validation set of activity parameter. + :paramtype validation_set: list[~azure.mgmt.automation.models.ActivityParameterValidationSet] + """ super(ActivityParameter, self).__init__(**kwargs) self.name = name self.type = type @@ -208,10 +270,10 @@ def __init__( class ActivityParameterSet(msrest.serialization.Model): """Definition of the activity parameter set. - :param name: Gets or sets the name of the activity parameter set. - :type name: str - :param parameters: Gets or sets the parameters of the activity parameter set. - :type parameters: list[~azure.mgmt.automation.models.ActivityParameter] + :ivar name: Gets or sets the name of the activity parameter set. + :vartype name: str + :ivar parameters: Gets or sets the parameters of the activity parameter set. + :vartype parameters: list[~azure.mgmt.automation.models.ActivityParameter] """ _attribute_map = { @@ -223,9 +285,15 @@ def __init__( self, *, name: Optional[str] = None, - parameters: Optional[List["ActivityParameter"]] = None, + parameters: Optional[List["_models.ActivityParameter"]] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the activity parameter set. + :paramtype name: str + :keyword parameters: Gets or sets the parameters of the activity parameter set. + :paramtype parameters: list[~azure.mgmt.automation.models.ActivityParameter] + """ super(ActivityParameterSet, self).__init__(**kwargs) self.name = name self.parameters = parameters @@ -234,8 +302,8 @@ def __init__( class ActivityParameterValidationSet(msrest.serialization.Model): """Definition of the activity parameter validation set. - :param member_value: Gets or sets the name of the activity parameter validation set member. - :type member_value: str + :ivar member_value: Gets or sets the name of the activity parameter validation set member. + :vartype member_value: str """ _attribute_map = { @@ -248,6 +316,10 @@ def __init__( member_value: Optional[str] = None, **kwargs ): + """ + :keyword member_value: Gets or sets the name of the activity parameter validation set member. + :paramtype member_value: str + """ super(ActivityParameterValidationSet, self).__init__(**kwargs) self.member_value = member_value @@ -255,12 +327,12 @@ def __init__( class AdvancedSchedule(msrest.serialization.Model): """The properties of the create Advanced Schedule. - :param week_days: Days of the week that the job should execute on. - :type week_days: list[str] - :param month_days: Days of the month that the job should execute on. Must be between 1 and 31. - :type month_days: list[int] - :param monthly_occurrences: Occurrences of days within a month. - :type monthly_occurrences: + :ivar week_days: Days of the week that the job should execute on. + :vartype week_days: list[str] + :ivar month_days: Days of the month that the job should execute on. Must be between 1 and 31. + :vartype month_days: list[int] + :ivar monthly_occurrences: Occurrences of days within a month. + :vartype monthly_occurrences: list[~azure.mgmt.automation.models.AdvancedScheduleMonthlyOccurrence] """ @@ -275,9 +347,19 @@ def __init__( *, week_days: Optional[List[str]] = None, month_days: Optional[List[int]] = None, - monthly_occurrences: Optional[List["AdvancedScheduleMonthlyOccurrence"]] = None, - **kwargs - ): + monthly_occurrences: Optional[List["_models.AdvancedScheduleMonthlyOccurrence"]] = None, + **kwargs + ): + """ + :keyword week_days: Days of the week that the job should execute on. + :paramtype week_days: list[str] + :keyword month_days: Days of the month that the job should execute on. Must be between 1 and + 31. + :paramtype month_days: list[int] + :keyword monthly_occurrences: Occurrences of days within a month. + :paramtype monthly_occurrences: + list[~azure.mgmt.automation.models.AdvancedScheduleMonthlyOccurrence] + """ super(AdvancedSchedule, self).__init__(**kwargs) self.week_days = week_days self.month_days = month_days @@ -287,12 +369,12 @@ def __init__( class AdvancedScheduleMonthlyOccurrence(msrest.serialization.Model): """The properties of the create advanced schedule monthly occurrence. - :param occurrence: Occurrence of the week within the month. Must be between 1 and 5. - :type occurrence: int - :param day: Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, - saturday, sunday. Possible values include: "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday", "Sunday". - :type day: str or ~azure.mgmt.automation.models.ScheduleDay + :ivar occurrence: Occurrence of the week within the month. Must be between 1 and 5. + :vartype occurrence: int + :ivar day: Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, + saturday, sunday. Known values are: "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", + "Saturday", "Sunday". + :vartype day: str or ~azure.mgmt.automation.models.ScheduleDay """ _attribute_map = { @@ -304,9 +386,17 @@ def __init__( self, *, occurrence: Optional[int] = None, - day: Optional[Union[str, "ScheduleDay"]] = None, + day: Optional[Union[str, "_models.ScheduleDay"]] = None, **kwargs ): + """ + :keyword occurrence: Occurrence of the week within the month. Must be between 1 and 5. + :paramtype occurrence: int + :keyword day: Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, + friday, saturday, sunday. Known values are: "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday", "Sunday". + :paramtype day: str or ~azure.mgmt.automation.models.ScheduleDay + """ super(AdvancedScheduleMonthlyOccurrence, self).__init__(**kwargs) self.occurrence = occurrence self.day = day @@ -315,14 +405,14 @@ def __init__( class AgentRegistration(msrest.serialization.Model): """Definition of the agent registration information type. - :param dsc_meta_configuration: Gets or sets the dsc meta configuration. - :type dsc_meta_configuration: str - :param endpoint: Gets or sets the dsc server endpoint. - :type endpoint: str - :param keys: Gets or sets the agent registration keys. - :type keys: ~azure.mgmt.automation.models.AgentRegistrationKeys - :param id: Gets or sets the id. - :type id: str + :ivar dsc_meta_configuration: Gets or sets the dsc meta configuration. + :vartype dsc_meta_configuration: str + :ivar endpoint: Gets or sets the dsc server endpoint. + :vartype endpoint: str + :ivar keys: Gets or sets the agent registration keys. + :vartype keys: ~azure.mgmt.automation.models.AgentRegistrationKeys + :ivar id: Gets or sets the id. + :vartype id: str """ _attribute_map = { @@ -337,10 +427,20 @@ def __init__( *, dsc_meta_configuration: Optional[str] = None, endpoint: Optional[str] = None, - keys: Optional["AgentRegistrationKeys"] = None, + keys: Optional["_models.AgentRegistrationKeys"] = None, id: Optional[str] = None, **kwargs ): + """ + :keyword dsc_meta_configuration: Gets or sets the dsc meta configuration. + :paramtype dsc_meta_configuration: str + :keyword endpoint: Gets or sets the dsc server endpoint. + :paramtype endpoint: str + :keyword keys: Gets or sets the agent registration keys. + :paramtype keys: ~azure.mgmt.automation.models.AgentRegistrationKeys + :keyword id: Gets or sets the id. + :paramtype id: str + """ super(AgentRegistration, self).__init__(**kwargs) self.dsc_meta_configuration = dsc_meta_configuration self.endpoint = endpoint @@ -351,10 +451,10 @@ def __init__( class AgentRegistrationKeys(msrest.serialization.Model): """Definition of the agent registration keys. - :param primary: Gets or sets the primary key. - :type primary: str - :param secondary: Gets or sets the secondary key. - :type secondary: str + :ivar primary: Gets or sets the primary key. + :vartype primary: str + :ivar secondary: Gets or sets the secondary key. + :vartype secondary: str """ _attribute_map = { @@ -369,6 +469,12 @@ def __init__( secondary: Optional[str] = None, **kwargs ): + """ + :keyword primary: Gets or sets the primary key. + :paramtype primary: str + :keyword secondary: Gets or sets the secondary key. + :paramtype secondary: str + """ super(AgentRegistrationKeys, self).__init__(**kwargs) self.primary = primary self.secondary = secondary @@ -379,9 +485,9 @@ class AgentRegistrationRegenerateKeyParameter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. Gets or sets the agent registration key name - primary or secondary. - Possible values include: "primary", "secondary". - :type key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName + :ivar key_name: Required. Gets or sets the agent registration key name - primary or secondary. + Known values are: "primary", "secondary". + :vartype key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName """ _validation = { @@ -395,9 +501,14 @@ class AgentRegistrationRegenerateKeyParameter(msrest.serialization.Model): def __init__( self, *, - key_name: Union[str, "AgentRegistrationKeyName"], + key_name: Union[str, "_models.AgentRegistrationKeyName"], **kwargs ): + """ + :keyword key_name: Required. Gets or sets the agent registration key name - primary or + secondary. Known values are: "primary", "secondary". + :paramtype key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName + """ super(AgentRegistrationRegenerateKeyParameter, self).__init__(**kwargs) self.key_name = key_name @@ -431,6 +542,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -448,10 +561,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str """ _validation = { @@ -475,6 +588,12 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -491,30 +610,49 @@ class AutomationAccount(TrackedResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param sku: Gets or sets the SKU of account. - :type sku: ~azure.mgmt.automation.models.Sku - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :ivar state: Gets status of account. Possible values include: "Ok", "Unavailable", "Suspended". + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.automation.models.Identity + :ivar system_data: Resource system metadata. + :vartype system_data: ~azure.mgmt.automation.models.SystemData + :ivar sku: Gets or sets the SKU of account. + :vartype sku: ~azure.mgmt.automation.models.Sku + :ivar last_modified_by: Gets or sets the last modified by. + :vartype last_modified_by: str + :ivar state: Gets status of account. Known values are: "Ok", "Unavailable", "Suspended". :vartype state: str or ~azure.mgmt.automation.models.AutomationAccountState :ivar creation_time: Gets the creation time. :vartype creation_time: ~datetime.datetime :ivar last_modified_time: Gets the last modified time. :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar description: Gets or sets the description. + :vartype description: str + :ivar encryption: Encryption properties for the automation account. + :vartype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :ivar private_endpoint_connections: List of Automation operations supported by the Automation + resource provider. + :vartype private_endpoint_connections: + list[~azure.mgmt.automation.models.PrivateEndpointConnection] + :ivar public_network_access: Indicates whether traffic on the non-ARM endpoint (Webhook/Agent) + is allowed from the public internet. + :vartype public_network_access: bool + :ivar disable_local_auth: Indicates whether requests using non-AAD authentication are blocked. + :vartype disable_local_auth: bool + :ivar automation_hybrid_service_url: URL of automation hybrid service which is used for hybrid + worker on-boarding. + :vartype automation_hybrid_service_url: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, 'state': {'readonly': True}, 'creation_time': {'readonly': True}, 'last_modified_time': {'readonly': True}, @@ -527,12 +665,19 @@ class AutomationAccount(TrackedResource): 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'sku': {'key': 'properties.sku', 'type': 'Sku'}, 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, 'state': {'key': 'properties.state', 'type': 'str'}, 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, 'description': {'key': 'properties.description', 'type': 'str'}, + 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperties'}, + 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'bool'}, + 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, + 'automation_hybrid_service_url': {'key': 'properties.automationHybridServiceUrl', 'type': 'str'}, } def __init__( @@ -541,39 +686,96 @@ def __init__( tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, etag: Optional[str] = None, - sku: Optional["Sku"] = None, + identity: Optional["_models.Identity"] = None, + sku: Optional["_models.Sku"] = None, last_modified_by: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + encryption: Optional["_models.EncryptionProperties"] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + public_network_access: Optional[bool] = None, + disable_local_auth: Optional[bool] = None, + automation_hybrid_service_url: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.automation.models.Identity + :keyword sku: Gets or sets the SKU of account. + :paramtype sku: ~azure.mgmt.automation.models.Sku + :keyword last_modified_by: Gets or sets the last modified by. + :paramtype last_modified_by: str + :keyword description: Gets or sets the description. + :paramtype description: str + :keyword encryption: Encryption properties for the automation account. + :paramtype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :keyword private_endpoint_connections: List of Automation operations supported by the + Automation resource provider. + :paramtype private_endpoint_connections: + list[~azure.mgmt.automation.models.PrivateEndpointConnection] + :keyword public_network_access: Indicates whether traffic on the non-ARM endpoint + (Webhook/Agent) is allowed from the public internet. + :paramtype public_network_access: bool + :keyword disable_local_auth: Indicates whether requests using non-AAD authentication are + blocked. + :paramtype disable_local_auth: bool + :keyword automation_hybrid_service_url: URL of automation hybrid service which is used for + hybrid worker on-boarding. + :paramtype automation_hybrid_service_url: str + """ super(AutomationAccount, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag + self.identity = identity + self.system_data = None self.sku = sku self.last_modified_by = last_modified_by self.state = None self.creation_time = None self.last_modified_time = None self.description = description + self.encryption = encryption + self.private_endpoint_connections = private_endpoint_connections + self.public_network_access = public_network_access + self.disable_local_auth = disable_local_auth + self.automation_hybrid_service_url = automation_hybrid_service_url class AutomationAccountCreateOrUpdateParameters(msrest.serialization.Model): """The parameters supplied to the create or update automation account operation. - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar identity: Sets the identity property for automation account. + :vartype identity: ~azure.mgmt.automation.models.Identity + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar sku: Gets or sets account SKU. + :vartype sku: ~azure.mgmt.automation.models.Sku + :ivar encryption: Set the encryption properties for the automation account. + :vartype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :ivar public_network_access: Indicates whether traffic on the non-ARM endpoint (Webhook/Agent) + is allowed from the public internet. + :vartype public_network_access: bool + :ivar disable_local_auth: Indicates whether requests using non-AAD authentication are blocked. + :vartype disable_local_auth: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'sku': {'key': 'properties.sku', 'type': 'Sku'}, + 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperties'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'bool'}, + 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, } def __init__( @@ -581,24 +783,52 @@ def __init__( *, name: Optional[str] = None, location: Optional[str] = None, + identity: Optional["_models.Identity"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - **kwargs - ): + sku: Optional["_models.Sku"] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + public_network_access: Optional[bool] = None, + disable_local_auth: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword identity: Sets the identity property for automation account. + :paramtype identity: ~azure.mgmt.automation.models.Identity + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword sku: Gets or sets account SKU. + :paramtype sku: ~azure.mgmt.automation.models.Sku + :keyword encryption: Set the encryption properties for the automation account. + :paramtype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :keyword public_network_access: Indicates whether traffic on the non-ARM endpoint + (Webhook/Agent) is allowed from the public internet. + :paramtype public_network_access: bool + :keyword disable_local_auth: Indicates whether requests using non-AAD authentication are + blocked. + :paramtype disable_local_auth: bool + """ super(AutomationAccountCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location + self.identity = identity self.tags = tags self.sku = sku + self.encryption = encryption + self.public_network_access = public_network_access + self.disable_local_auth = disable_local_auth class AutomationAccountListResult(msrest.serialization.Model): """The response model for the list account operation. - :param value: Gets or sets list of accounts. - :type value: list[~azure.mgmt.automation.models.AutomationAccount] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets list of accounts. + :vartype value: list[~azure.mgmt.automation.models.AutomationAccount] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -609,10 +839,16 @@ class AutomationAccountListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AutomationAccount"]] = None, + value: Optional[List["_models.AutomationAccount"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets list of accounts. + :paramtype value: list[~azure.mgmt.automation.models.AutomationAccount] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(AutomationAccountListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -621,21 +857,34 @@ def __init__( class AutomationAccountUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update automation account operation. - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar identity: Sets the identity property for automation account. + :vartype identity: ~azure.mgmt.automation.models.Identity + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar sku: Gets or sets account SKU. + :vartype sku: ~azure.mgmt.automation.models.Sku + :ivar encryption: Set the encryption properties for the automation account. + :vartype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :ivar public_network_access: Indicates whether traffic on the non-ARM endpoint (Webhook/Agent) + is allowed from the public internet. + :vartype public_network_access: bool + :ivar disable_local_auth: Indicates whether requests using non-AAD authentication are blocked. + :vartype disable_local_auth: bool """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'sku': {'key': 'properties.sku', 'type': 'Sku'}, + 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionProperties'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'bool'}, + 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, } def __init__( @@ -643,26 +892,54 @@ def __init__( *, name: Optional[str] = None, location: Optional[str] = None, + identity: Optional["_models.Identity"] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - **kwargs - ): + sku: Optional["_models.Sku"] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + public_network_access: Optional[bool] = None, + disable_local_auth: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword identity: Sets the identity property for automation account. + :paramtype identity: ~azure.mgmt.automation.models.Identity + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword sku: Gets or sets account SKU. + :paramtype sku: ~azure.mgmt.automation.models.Sku + :keyword encryption: Set the encryption properties for the automation account. + :paramtype encryption: ~azure.mgmt.automation.models.EncryptionProperties + :keyword public_network_access: Indicates whether traffic on the non-ARM endpoint + (Webhook/Agent) is allowed from the public internet. + :paramtype public_network_access: bool + :keyword disable_local_auth: Indicates whether requests using non-AAD authentication are + blocked. + :paramtype disable_local_auth: bool + """ super(AutomationAccountUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location + self.identity = identity self.tags = tags self.sku = sku + self.encryption = encryption + self.public_network_access = public_network_access + self.disable_local_auth = disable_local_auth class AzureQueryProperties(msrest.serialization.Model): """Azure query for the update configuration. - :param scope: List of Subscription or Resource Group ARM Ids. - :type scope: list[str] - :param locations: List of locations to scope the query to. - :type locations: list[str] - :param tag_settings: Tag settings for the VM. - :type tag_settings: ~azure.mgmt.automation.models.TagSettingsProperties + :ivar scope: List of Subscription or Resource Group ARM Ids. + :vartype scope: list[str] + :ivar locations: List of locations to scope the query to. + :vartype locations: list[str] + :ivar tag_settings: Tag settings for the VM. + :vartype tag_settings: ~azure.mgmt.automation.models.TagSettingsProperties """ _attribute_map = { @@ -676,16 +953,58 @@ def __init__( *, scope: Optional[List[str]] = None, locations: Optional[List[str]] = None, - tag_settings: Optional["TagSettingsProperties"] = None, + tag_settings: Optional["_models.TagSettingsProperties"] = None, **kwargs ): + """ + :keyword scope: List of Subscription or Resource Group ARM Ids. + :paramtype scope: list[str] + :keyword locations: List of locations to scope the query to. + :paramtype locations: list[str] + :keyword tag_settings: Tag settings for the VM. + :paramtype tag_settings: ~azure.mgmt.automation.models.TagSettingsProperties + """ super(AzureQueryProperties, self).__init__(**kwargs) self.scope = scope self.locations = locations self.tag_settings = tag_settings -class Certificate(Resource): +class ProxyResource(Resource): + """ARM proxy resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class Certificate(ProxyResource): """Definition of the certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -706,8 +1025,8 @@ class Certificate(Resource): :vartype creation_time: ~datetime.datetime :ivar last_modified_time: Gets the last modified time. :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -739,6 +1058,10 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Certificate, self).__init__(**kwargs) self.thumbprint = None self.expiry_time = None @@ -753,16 +1076,16 @@ class CertificateCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the certificate. - :type name: str - :param base64_value: Required. Gets or sets the base64 encoded value of the certificate. - :type base64_value: str - :param description: Gets or sets the description of the certificate. - :type description: str - :param thumbprint: Gets or sets the thumbprint of the certificate. - :type thumbprint: str - :param is_exportable: Gets or sets the is exportable flag of the certificate. - :type is_exportable: bool + :ivar name: Required. Gets or sets the name of the certificate. + :vartype name: str + :ivar base64_value: Required. Gets or sets the base64 encoded value of the certificate. + :vartype base64_value: str + :ivar description: Gets or sets the description of the certificate. + :vartype description: str + :ivar thumbprint: Gets or sets the thumbprint of the certificate. + :vartype thumbprint: str + :ivar is_exportable: Gets or sets the is exportable flag of the certificate. + :vartype is_exportable: bool """ _validation = { @@ -788,6 +1111,18 @@ def __init__( is_exportable: Optional[bool] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the certificate. + :paramtype name: str + :keyword base64_value: Required. Gets or sets the base64 encoded value of the certificate. + :paramtype base64_value: str + :keyword description: Gets or sets the description of the certificate. + :paramtype description: str + :keyword thumbprint: Gets or sets the thumbprint of the certificate. + :paramtype thumbprint: str + :keyword is_exportable: Gets or sets the is exportable flag of the certificate. + :paramtype is_exportable: bool + """ super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.base64_value = base64_value @@ -799,10 +1134,10 @@ def __init__( class CertificateListResult(msrest.serialization.Model): """The response model for the list certificate operation. - :param value: Gets or sets a list of certificates. - :type value: list[~azure.mgmt.automation.models.Certificate] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of certificates. + :vartype value: list[~azure.mgmt.automation.models.Certificate] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -813,10 +1148,16 @@ class CertificateListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Certificate"]] = None, + value: Optional[List["_models.Certificate"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of certificates. + :paramtype value: list[~azure.mgmt.automation.models.Certificate] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(CertificateListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -825,10 +1166,10 @@ def __init__( class CertificateUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update certificate operation. - :param name: Gets or sets the name of the certificate. - :type name: str - :param description: Gets or sets the description of the certificate. - :type description: str + :ivar name: Gets or sets the name of the certificate. + :vartype name: str + :ivar description: Gets or sets the description of the certificate. + :vartype description: str """ _attribute_map = { @@ -843,12 +1184,50 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the certificate. + :paramtype name: str + :keyword description: Gets or sets the description of the certificate. + :paramtype description: str + """ super(CertificateUpdateParameters, self).__init__(**kwargs) self.name = name self.description = description -class Connection(Resource): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class Connection(ProxyResource): """Definition of the connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -859,16 +1238,16 @@ class Connection(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param connection_type: Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty + :ivar connection_type: Gets or sets the connectionType of the connection. + :vartype connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty :ivar field_definition_values: Gets the field definition values of the connection. :vartype field_definition_values: dict[str, str] :ivar creation_time: Gets the creation time. :vartype creation_time: ~datetime.datetime :ivar last_modified_time: Gets the last modified time. :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -894,10 +1273,16 @@ class Connection(Resource): def __init__( self, *, - connection_type: Optional["ConnectionTypeAssociationProperty"] = None, + connection_type: Optional["_models.ConnectionTypeAssociationProperty"] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword connection_type: Gets or sets the connectionType of the connection. + :paramtype connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Connection, self).__init__(**kwargs) self.connection_type = connection_type self.field_definition_values = None @@ -911,14 +1296,14 @@ class ConnectionCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param connection_type: Required. Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty - :param field_definition_values: Gets or sets the field definition properties of the connection. - :type field_definition_values: dict[str, str] + :ivar name: Required. Gets or sets the name of the connection. + :vartype name: str + :ivar description: Gets or sets the description of the connection. + :vartype description: str + :ivar connection_type: Required. Gets or sets the connectionType of the connection. + :vartype connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty + :ivar field_definition_values: Gets or sets the field definition properties of the connection. + :vartype field_definition_values: dict[str, str] """ _validation = { @@ -937,11 +1322,22 @@ def __init__( self, *, name: str, - connection_type: "ConnectionTypeAssociationProperty", + connection_type: "_models.ConnectionTypeAssociationProperty", description: Optional[str] = None, field_definition_values: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the connection. + :paramtype name: str + :keyword description: Gets or sets the description of the connection. + :paramtype description: str + :keyword connection_type: Required. Gets or sets the connectionType of the connection. + :paramtype connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty + :keyword field_definition_values: Gets or sets the field definition properties of the + connection. + :paramtype field_definition_values: dict[str, str] + """ super(ConnectionCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.description = description @@ -952,10 +1348,10 @@ def __init__( class ConnectionListResult(msrest.serialization.Model): """The response model for the list connection operation. - :param value: Gets or sets a list of connection. - :type value: list[~azure.mgmt.automation.models.Connection] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of connection. + :vartype value: list[~azure.mgmt.automation.models.Connection] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -966,10 +1362,16 @@ class ConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Connection"]] = None, + value: Optional[List["_models.Connection"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of connection. + :paramtype value: list[~azure.mgmt.automation.models.Connection] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(ConnectionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -986,16 +1388,16 @@ class ConnectionType(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool + :ivar is_global: Gets or sets a Boolean value to indicate if the connection type is global. + :vartype is_global: bool :ivar field_definitions: Gets the field definitions of the connection type. :vartype field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] :ivar creation_time: Gets the creation time. :vartype creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -1025,6 +1427,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword is_global: Gets or sets a Boolean value to indicate if the connection type is global. + :paramtype is_global: bool + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(ConnectionType, self).__init__(**kwargs) self.id = None self.name = None @@ -1039,8 +1449,8 @@ def __init__( class ConnectionTypeAssociationProperty(msrest.serialization.Model): """The connection type property associated with the entity. - :param name: Gets or sets the name of the connection type. - :type name: str + :ivar name: Gets or sets the name of the connection type. + :vartype name: str """ _attribute_map = { @@ -1053,6 +1463,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the connection type. + :paramtype name: str + """ super(ConnectionTypeAssociationProperty, self).__init__(**kwargs) self.name = name @@ -1062,12 +1476,12 @@ class ConnectionTypeCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the connection type. - :type name: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool - :param field_definitions: Required. Gets or sets the field definitions of the connection type. - :type field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] + :ivar name: Required. Gets or sets the name of the connection type. + :vartype name: str + :ivar is_global: Gets or sets a Boolean value to indicate if the connection type is global. + :vartype is_global: bool + :ivar field_definitions: Required. Gets or sets the field definitions of the connection type. + :vartype field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] """ _validation = { @@ -1085,10 +1499,19 @@ def __init__( self, *, name: str, - field_definitions: Dict[str, "FieldDefinition"], + field_definitions: Dict[str, "_models.FieldDefinition"], is_global: Optional[bool] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the connection type. + :paramtype name: str + :keyword is_global: Gets or sets a Boolean value to indicate if the connection type is global. + :paramtype is_global: bool + :keyword field_definitions: Required. Gets or sets the field definitions of the connection + type. + :paramtype field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] + """ super(ConnectionTypeCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.is_global = is_global @@ -1098,10 +1521,10 @@ def __init__( class ConnectionTypeListResult(msrest.serialization.Model): """The response model for the list connection type operation. - :param value: Gets or sets a list of connection types. - :type value: list[~azure.mgmt.automation.models.ConnectionType] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of connection types. + :vartype value: list[~azure.mgmt.automation.models.ConnectionType] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -1112,10 +1535,16 @@ class ConnectionTypeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ConnectionType"]] = None, + value: Optional[List["_models.ConnectionType"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of connection types. + :paramtype value: list[~azure.mgmt.automation.models.ConnectionType] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(ConnectionTypeListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1124,12 +1553,12 @@ def __init__( class ConnectionUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update connection operation. - :param name: Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param field_definition_values: Gets or sets the field definition values of the connection. - :type field_definition_values: dict[str, str] + :ivar name: Gets or sets the name of the connection. + :vartype name: str + :ivar description: Gets or sets the description of the connection. + :vartype description: str + :ivar field_definition_values: Gets or sets the field definition values of the connection. + :vartype field_definition_values: dict[str, str] """ _attribute_map = { @@ -1146,6 +1575,14 @@ def __init__( field_definition_values: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the connection. + :paramtype name: str + :keyword description: Gets or sets the description of the connection. + :paramtype description: str + :keyword field_definition_values: Gets or sets the field definition values of the connection. + :paramtype field_definition_values: dict[str, str] + """ super(ConnectionUpdateParameters, self).__init__(**kwargs) self.name = name self.description = description @@ -1157,10 +1594,10 @@ class ContentHash(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param algorithm: Required. Gets or sets the content hash algorithm used to hash the content. - :type algorithm: str - :param value: Required. Gets or sets expected hash value of the content. - :type value: str + :ivar algorithm: Required. Gets or sets the content hash algorithm used to hash the content. + :vartype algorithm: str + :ivar value: Required. Gets or sets expected hash value of the content. + :vartype value: str """ _validation = { @@ -1180,6 +1617,12 @@ def __init__( value: str, **kwargs ): + """ + :keyword algorithm: Required. Gets or sets the content hash algorithm used to hash the content. + :paramtype algorithm: str + :keyword value: Required. Gets or sets expected hash value of the content. + :paramtype value: str + """ super(ContentHash, self).__init__(**kwargs) self.algorithm = algorithm self.value = value @@ -1188,12 +1631,12 @@ def __init__( class ContentLink(msrest.serialization.Model): """Definition of the content link. - :param uri: Gets or sets the uri of the runbook content. - :type uri: str - :param content_hash: Gets or sets the hash. - :type content_hash: ~azure.mgmt.automation.models.ContentHash - :param version: Gets or sets the version of the content. - :type version: str + :ivar uri: Gets or sets the uri of the runbook content. + :vartype uri: str + :ivar content_hash: Gets or sets the hash. + :vartype content_hash: ~azure.mgmt.automation.models.ContentHash + :ivar version: Gets or sets the version of the content. + :vartype version: str """ _attribute_map = { @@ -1206,10 +1649,18 @@ def __init__( self, *, uri: Optional[str] = None, - content_hash: Optional["ContentHash"] = None, + content_hash: Optional["_models.ContentHash"] = None, version: Optional[str] = None, **kwargs ): + """ + :keyword uri: Gets or sets the uri of the runbook content. + :paramtype uri: str + :keyword content_hash: Gets or sets the hash. + :paramtype content_hash: ~azure.mgmt.automation.models.ContentHash + :keyword version: Gets or sets the version of the content. + :paramtype version: str + """ super(ContentLink, self).__init__(**kwargs) self.uri = uri self.content_hash = content_hash @@ -1219,15 +1670,14 @@ def __init__( class ContentSource(msrest.serialization.Model): """Definition of the content source. - :param hash: Gets or sets the hash. - :type hash: ~azure.mgmt.automation.models.ContentHash - :param type: Gets or sets the content source type. Possible values include: "embeddedContent", - "uri". - :type type: str or ~azure.mgmt.automation.models.ContentSourceType - :param value: Gets or sets the value of the content. This is based on the content source type. - :type value: str - :param version: Gets or sets the version of the content. - :type version: str + :ivar hash: Gets or sets the hash. + :vartype hash: ~azure.mgmt.automation.models.ContentHash + :ivar type: Gets or sets the content source type. Known values are: "embeddedContent", "uri". + :vartype type: str or ~azure.mgmt.automation.models.ContentSourceType + :ivar value: Gets or sets the value of the content. This is based on the content source type. + :vartype value: str + :ivar version: Gets or sets the version of the content. + :vartype version: str """ _attribute_map = { @@ -1240,12 +1690,24 @@ class ContentSource(msrest.serialization.Model): def __init__( self, *, - hash: Optional["ContentHash"] = None, - type: Optional[Union[str, "ContentSourceType"]] = None, + hash: Optional["_models.ContentHash"] = None, + type: Optional[Union[str, "_models.ContentSourceType"]] = None, value: Optional[str] = None, version: Optional[str] = None, **kwargs ): + """ + :keyword hash: Gets or sets the hash. + :paramtype hash: ~azure.mgmt.automation.models.ContentHash + :keyword type: Gets or sets the content source type. Known values are: "embeddedContent", + "uri". + :paramtype type: str or ~azure.mgmt.automation.models.ContentSourceType + :keyword value: Gets or sets the value of the content. This is based on the content source + type. + :paramtype value: str + :keyword version: Gets or sets the version of the content. + :paramtype version: str + """ super(ContentSource, self).__init__(**kwargs) self.hash = hash self.type = type @@ -1253,7 +1715,7 @@ def __init__( self.version = version -class Credential(Resource): +class Credential(ProxyResource): """Definition of the credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -1270,8 +1732,8 @@ class Credential(Resource): :vartype creation_time: ~datetime.datetime :ivar last_modified_time: Gets the last modified time. :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -1299,6 +1761,10 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Credential, self).__init__(**kwargs) self.user_name = None self.creation_time = None @@ -1311,14 +1777,14 @@ class CredentialCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the credential. - :type name: str - :param user_name: Required. Gets or sets the user name of the credential. - :type user_name: str - :param password: Required. Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str + :ivar name: Required. Gets or sets the name of the credential. + :vartype name: str + :ivar user_name: Required. Gets or sets the user name of the credential. + :vartype user_name: str + :ivar password: Required. Gets or sets the password of the credential. + :vartype password: str + :ivar description: Gets or sets the description of the credential. + :vartype description: str """ _validation = { @@ -1343,6 +1809,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the credential. + :paramtype name: str + :keyword user_name: Required. Gets or sets the user name of the credential. + :paramtype user_name: str + :keyword password: Required. Gets or sets the password of the credential. + :paramtype password: str + :keyword description: Gets or sets the description of the credential. + :paramtype description: str + """ super(CredentialCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.user_name = user_name @@ -1353,10 +1829,10 @@ def __init__( class CredentialListResult(msrest.serialization.Model): """The response model for the list credential operation. - :param value: Gets or sets a list of credentials. - :type value: list[~azure.mgmt.automation.models.Credential] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of credentials. + :vartype value: list[~azure.mgmt.automation.models.Credential] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -1367,10 +1843,16 @@ class CredentialListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Credential"]] = None, + value: Optional[List["_models.Credential"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of credentials. + :paramtype value: list[~azure.mgmt.automation.models.Credential] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(CredentialListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1379,14 +1861,14 @@ def __init__( class CredentialUpdateParameters(msrest.serialization.Model): """The parameters supplied to the Update credential operation. - :param name: Gets or sets the name of the credential. - :type name: str - :param user_name: Gets or sets the user name of the credential. - :type user_name: str - :param password: Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str + :ivar name: Gets or sets the name of the credential. + :vartype name: str + :ivar user_name: Gets or sets the user name of the credential. + :vartype user_name: str + :ivar password: Gets or sets the password of the credential. + :vartype password: str + :ivar description: Gets or sets the description of the credential. + :vartype description: str """ _attribute_map = { @@ -1405,6 +1887,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the credential. + :paramtype name: str + :keyword user_name: Gets or sets the user name of the credential. + :paramtype user_name: str + :keyword password: Gets or sets the password of the credential. + :paramtype password: str + :keyword description: Gets or sets the description of the credential. + :paramtype description: str + """ super(CredentialUpdateParameters, self).__init__(**kwargs) self.name = name self.user_name = user_name @@ -1412,7 +1904,7 @@ def __init__( self.description = description -class DscCompilationJob(Resource): +class DscCompilationJob(ProxyResource): """Definition of the Dsc Compilation job. Variables are only populated by the server, and will be ignored when sending a request. @@ -1423,26 +1915,26 @@ class DscCompilationJob(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param configuration: Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :ivar configuration: Gets or sets the configuration. + :vartype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty :ivar started_by: Gets the compilation job started by. :vartype started_by: str :ivar job_id: Gets the id of the job. :vartype job_id: str :ivar creation_time: Gets the creation time of the job. :vartype creation_time: ~datetime.datetime - :param provisioning_state: The current provisioning state of the job. Possible values include: + :ivar provisioning_state: The current provisioning state of the job. Known values are: "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be + :vartype provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState + :ivar run_on: Gets or sets the runOn which specifies the group name where the job is to be executed. - :type run_on: str - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str + :vartype run_on: str + :ivar status: Gets or sets the status of the job. Known values are: "New", "Activating", + "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", + "Suspending", "Stopping", "Resuming", "Removing". + :vartype status: str or ~azure.mgmt.automation.models.JobStatus + :ivar status_details: Gets or sets the status details of the job. + :vartype status_details: str :ivar start_time: Gets the start time of the job. :vartype start_time: ~datetime.datetime :ivar end_time: Gets the end time of the job. @@ -1453,8 +1945,8 @@ class DscCompilationJob(Resource): :vartype last_modified_time: ~datetime.datetime :ivar last_status_modified_time: Gets the last status modified time of the job. :vartype last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] """ _validation = { @@ -1494,14 +1986,32 @@ class DscCompilationJob(Resource): def __init__( self, *, - configuration: Optional["DscConfigurationAssociationProperty"] = None, - provisioning_state: Optional[Union[str, "JobProvisioningState"]] = None, + configuration: Optional["_models.DscConfigurationAssociationProperty"] = None, + provisioning_state: Optional[Union[str, "_models.JobProvisioningState"]] = None, run_on: Optional[str] = None, - status: Optional[Union[str, "JobStatus"]] = None, + status: Optional[Union[str, "_models.JobStatus"]] = None, status_details: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword configuration: Gets or sets the configuration. + :paramtype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :keyword provisioning_state: The current provisioning state of the job. Known values are: + "Failed", "Succeeded", "Suspended", "Processing". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState + :keyword run_on: Gets or sets the runOn which specifies the group name where the job is to be + executed. + :paramtype run_on: str + :keyword status: Gets or sets the status of the job. Known values are: "New", "Activating", + "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", + "Suspending", "Stopping", "Resuming", "Removing". + :paramtype status: str or ~azure.mgmt.automation.models.JobStatus + :keyword status_details: Gets or sets the status details of the job. + :paramtype status_details: str + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + """ super(DscCompilationJob, self).__init__(**kwargs) self.configuration = configuration self.started_by = None @@ -1524,19 +2034,19 @@ class DscCompilationJobCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param configuration: Required. Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param increment_node_configuration_build: If a new build version of NodeConfiguration is + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar configuration: Required. Gets or sets the configuration. + :vartype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] + :ivar increment_node_configuration_build: If a new build version of NodeConfiguration is required. - :type increment_node_configuration_build: bool + :vartype increment_node_configuration_build: bool """ _validation = { @@ -1555,7 +2065,7 @@ class DscCompilationJobCreateParameters(msrest.serialization.Model): def __init__( self, *, - configuration: "DscConfigurationAssociationProperty", + configuration: "_models.DscConfigurationAssociationProperty", name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, @@ -1563,6 +2073,21 @@ def __init__( increment_node_configuration_build: Optional[bool] = None, **kwargs ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword configuration: Required. Gets or sets the configuration. + :paramtype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + :keyword increment_node_configuration_build: If a new build version of NodeConfiguration is + required. + :paramtype increment_node_configuration_build: bool + """ super(DscCompilationJobCreateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -1575,10 +2100,10 @@ def __init__( class DscCompilationJobListResult(msrest.serialization.Model): """The response model for the list job operation. - :param value: Gets or sets a list of Dsc Compilation jobs. - :type value: list[~azure.mgmt.automation.models.DscCompilationJob] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of Dsc Compilation jobs. + :vartype value: list[~azure.mgmt.automation.models.DscCompilationJob] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -1589,10 +2114,16 @@ class DscCompilationJobListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DscCompilationJob"]] = None, + value: Optional[List["_models.DscCompilationJob"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of Dsc Compilation jobs. + :paramtype value: list[~azure.mgmt.automation.models.DscCompilationJob] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(DscCompilationJobListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1609,41 +2140,40 @@ class DscConfiguration(TrackedResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :ivar provisioning_state: Gets or sets the provisioning state of the configuration. Default - value: "Succeeded". + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar provisioning_state: Gets or sets the provisioning state of the configuration. The only + acceptable values to pass in are None and "Succeeded". The default value is None. :vartype provisioning_state: str - :param job_count: Gets or sets the job count of the configuration. - :type job_count: int - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param state: Gets or sets the state of the configuration. Possible values include: "New", - "Edit", "Published". - :type state: str or ~azure.mgmt.automation.models.DscConfigurationState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param node_configuration_count: Gets the number of compiled node configurations. - :type node_configuration_count: int - :param description: Gets or sets the description. - :type description: str + :ivar job_count: Gets or sets the job count of the configuration. + :vartype job_count: int + :ivar parameters: Gets or sets the configuration parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :ivar source: Gets or sets the source. + :vartype source: ~azure.mgmt.automation.models.ContentSource + :ivar state: Gets or sets the state of the configuration. Known values are: "New", "Edit", + "Published". + :vartype state: str or ~azure.mgmt.automation.models.DscConfigurationState + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar node_configuration_count: Gets the number of compiled node configurations. + :vartype node_configuration_count: int + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, } _attribute_map = { @@ -1665,18 +2195,17 @@ class DscConfiguration(TrackedResource): 'description': {'key': 'properties.description', 'type': 'str'}, } - provisioning_state = "Succeeded" - def __init__( self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, etag: Optional[str] = None, + provisioning_state: Optional[str] = None, job_count: Optional[int] = None, - parameters: Optional[Dict[str, "DscConfigurationParameter"]] = None, - source: Optional["ContentSource"] = None, - state: Optional[Union[str, "DscConfigurationState"]] = None, + parameters: Optional[Dict[str, "_models.DscConfigurationParameter"]] = None, + source: Optional["_models.ContentSource"] = None, + state: Optional[Union[str, "_models.DscConfigurationState"]] = None, log_verbose: Optional[bool] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, @@ -1684,8 +2213,39 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword provisioning_state: Gets or sets the provisioning state of the configuration. The only + acceptable values to pass in are None and "Succeeded". The default value is None. + :paramtype provisioning_state: str + :keyword job_count: Gets or sets the job count of the configuration. + :paramtype job_count: int + :keyword parameters: Gets or sets the configuration parameters. + :paramtype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :keyword source: Gets or sets the source. + :paramtype source: ~azure.mgmt.automation.models.ContentSource + :keyword state: Gets or sets the state of the configuration. Known values are: "New", "Edit", + "Published". + :paramtype state: str or ~azure.mgmt.automation.models.DscConfigurationState + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword node_configuration_count: Gets the number of compiled node configurations. + :paramtype node_configuration_count: int + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(DscConfiguration, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag + self.provisioning_state = provisioning_state self.job_count = job_count self.parameters = parameters self.source = source @@ -1700,8 +2260,8 @@ def __init__( class DscConfigurationAssociationProperty(msrest.serialization.Model): """The Dsc configuration property associated with the entity. - :param name: Gets or sets the name of the Dsc configuration. - :type name: str + :ivar name: Gets or sets the name of the Dsc configuration. + :vartype name: str """ _attribute_map = { @@ -1714,6 +2274,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the Dsc configuration. + :paramtype name: str + """ super(DscConfigurationAssociationProperty, self).__init__(**kwargs) self.name = name @@ -1723,22 +2287,22 @@ class DscConfigurationCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Required. Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar source: Required. Gets or sets the source. + :vartype source: ~azure.mgmt.automation.models.ContentSource + :ivar parameters: Gets or sets the configuration parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :ivar description: Gets or sets the description of the configuration. + :vartype description: str """ _validation = { @@ -1759,16 +2323,34 @@ class DscConfigurationCreateOrUpdateParameters(msrest.serialization.Model): def __init__( self, *, - source: "ContentSource", + source: "_models.ContentSource", name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, - parameters: Optional[Dict[str, "DscConfigurationParameter"]] = None, + parameters: Optional[Dict[str, "_models.DscConfigurationParameter"]] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword source: Required. Gets or sets the source. + :paramtype source: ~azure.mgmt.automation.models.ContentSource + :keyword parameters: Gets or sets the configuration parameters. + :paramtype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :keyword description: Gets or sets the description of the configuration. + :paramtype description: str + """ super(DscConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -1783,12 +2365,12 @@ def __init__( class DscConfigurationListResult(msrest.serialization.Model): """The response model for the list configuration operation. - :param value: Gets or sets a list of configurations. - :type value: list[~azure.mgmt.automation.models.DscConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of configurations matching filter criteria. - :type total_count: int + :ivar value: Gets or sets a list of configurations. + :vartype value: list[~azure.mgmt.automation.models.DscConfiguration] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str + :ivar total_count: Gets the total number of configurations matching filter criteria. + :vartype total_count: int """ _attribute_map = { @@ -1800,11 +2382,19 @@ class DscConfigurationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DscConfiguration"]] = None, + value: Optional[List["_models.DscConfiguration"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of configurations. + :paramtype value: list[~azure.mgmt.automation.models.DscConfiguration] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + :keyword total_count: Gets the total number of configurations matching filter criteria. + :paramtype total_count: int + """ super(DscConfigurationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1814,15 +2404,15 @@ def __init__( class DscConfigurationParameter(msrest.serialization.Model): """Definition of the configuration parameter type. - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str + :ivar type: Gets or sets the type of the parameter. + :vartype type: str + :ivar is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is mandatory + or not. + :vartype is_mandatory: bool + :ivar position: Get or sets the position of the parameter. + :vartype position: int + :ivar default_value: Gets or sets the default value of parameter. + :vartype default_value: str """ _attribute_map = { @@ -1841,6 +2431,17 @@ def __init__( default_value: Optional[str] = None, **kwargs ): + """ + :keyword type: Gets or sets the type of the parameter. + :paramtype type: str + :keyword is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is + mandatory or not. + :paramtype is_mandatory: bool + :keyword position: Get or sets the position of the parameter. + :paramtype position: int + :keyword default_value: Gets or sets the default value of parameter. + :paramtype default_value: str + """ super(DscConfigurationParameter, self).__init__(**kwargs) self.type = type self.is_mandatory = is_mandatory @@ -1851,20 +2452,20 @@ def __init__( class DscConfigurationUpdateParameters(msrest.serialization.Model): """The parameters supplied to the create or update configuration operation. - :param name: Gets or sets name of the resource. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar source: Gets or sets the source. + :vartype source: ~azure.mgmt.automation.models.ContentSource + :ivar parameters: Gets or sets the configuration parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :ivar description: Gets or sets the description of the configuration. + :vartype description: str """ _attribute_map = { @@ -1884,11 +2485,27 @@ def __init__( tags: Optional[Dict[str, str]] = None, log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, - source: Optional["ContentSource"] = None, - parameters: Optional[Dict[str, "DscConfigurationParameter"]] = None, + source: Optional["_models.ContentSource"] = None, + parameters: Optional[Dict[str, "_models.DscConfigurationParameter"]] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword source: Gets or sets the source. + :paramtype source: ~azure.mgmt.automation.models.ContentSource + :keyword parameters: Gets or sets the configuration parameters. + :paramtype parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] + :keyword description: Gets or sets the description of the configuration. + :paramtype description: str + """ super(DscConfigurationUpdateParameters, self).__init__(**kwargs) self.name = name self.tags = tags @@ -1902,24 +2519,24 @@ def __init__( class DscMetaConfiguration(msrest.serialization.Model): """Definition of the DSC Meta Configuration. - :param configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins value + :ivar configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins value of the meta configuration. - :type configuration_mode_frequency_mins: int - :param reboot_node_if_needed: Gets or sets the RebootNodeIfNeeded value of the meta + :vartype configuration_mode_frequency_mins: int + :ivar reboot_node_if_needed: Gets or sets the RebootNodeIfNeeded value of the meta configuration. - :type reboot_node_if_needed: bool - :param configuration_mode: Gets or sets the ConfigurationMode value of the meta configuration. - :type configuration_mode: str - :param action_after_reboot: Gets or sets the ActionAfterReboot value of the meta configuration. - :type action_after_reboot: str - :param certificate_id: Gets or sets the CertificateId value of the meta configuration. - :type certificate_id: str - :param refresh_frequency_mins: Gets or sets the RefreshFrequencyMins value of the meta + :vartype reboot_node_if_needed: bool + :ivar configuration_mode: Gets or sets the ConfigurationMode value of the meta configuration. + :vartype configuration_mode: str + :ivar action_after_reboot: Gets or sets the ActionAfterReboot value of the meta configuration. + :vartype action_after_reboot: str + :ivar certificate_id: Gets or sets the CertificateId value of the meta configuration. + :vartype certificate_id: str + :ivar refresh_frequency_mins: Gets or sets the RefreshFrequencyMins value of the meta configuration. - :type refresh_frequency_mins: int - :param allow_module_overwrite: Gets or sets the AllowModuleOverwrite value of the meta + :vartype refresh_frequency_mins: int + :ivar allow_module_overwrite: Gets or sets the AllowModuleOverwrite value of the meta configuration. - :type allow_module_overwrite: bool + :vartype allow_module_overwrite: bool """ _attribute_map = { @@ -1944,6 +2561,28 @@ def __init__( allow_module_overwrite: Optional[bool] = None, **kwargs ): + """ + :keyword configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins + value of the meta configuration. + :paramtype configuration_mode_frequency_mins: int + :keyword reboot_node_if_needed: Gets or sets the RebootNodeIfNeeded value of the meta + configuration. + :paramtype reboot_node_if_needed: bool + :keyword configuration_mode: Gets or sets the ConfigurationMode value of the meta + configuration. + :paramtype configuration_mode: str + :keyword action_after_reboot: Gets or sets the ActionAfterReboot value of the meta + configuration. + :paramtype action_after_reboot: str + :keyword certificate_id: Gets or sets the CertificateId value of the meta configuration. + :paramtype certificate_id: str + :keyword refresh_frequency_mins: Gets or sets the RefreshFrequencyMins value of the meta + configuration. + :paramtype refresh_frequency_mins: int + :keyword allow_module_overwrite: Gets or sets the AllowModuleOverwrite value of the meta + configuration. + :paramtype allow_module_overwrite: bool + """ super(DscMetaConfiguration, self).__init__(**kwargs) self.configuration_mode_frequency_mins = configuration_mode_frequency_mins self.reboot_node_if_needed = reboot_node_if_needed @@ -1954,7 +2593,7 @@ def __init__( self.allow_module_overwrite = allow_module_overwrite -class DscNode(Resource): +class DscNode(ProxyResource): """Definition of a DscNode. Variables are only populated by the server, and will be ignored when sending a request. @@ -1965,28 +2604,28 @@ class DscNode(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param last_seen: Gets or sets the last seen time of the node. - :type last_seen: ~datetime.datetime - :param registration_time: Gets or sets the registration time of the node. - :type registration_time: ~datetime.datetime - :param ip: Gets or sets the ip of the node. - :type ip: str - :param account_id: Gets or sets the account id of the node. - :type account_id: str - :param status: Gets or sets the status of the node. - :type status: str - :param node_id: Gets or sets the node id. - :type node_id: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param total_count: Gets the total number of records matching filter criteria. - :type total_count: int - :param extension_handler: Gets or sets the list of extensionHandler properties for a Node. - :type extension_handler: + :ivar last_seen: Gets or sets the last seen time of the node. + :vartype last_seen: ~datetime.datetime + :ivar registration_time: Gets or sets the registration time of the node. + :vartype registration_time: ~datetime.datetime + :ivar ip: Gets or sets the ip of the node. + :vartype ip: str + :ivar account_id: Gets or sets the account id of the node. + :vartype account_id: str + :ivar status: Gets or sets the status of the node. + :vartype status: str + :ivar node_id: Gets or sets the node id. + :vartype node_id: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar total_count: Gets the total number of records matching filter criteria. + :vartype total_count: int + :ivar extension_handler: Gets or sets the list of extensionHandler properties for a Node. + :vartype extension_handler: list[~azure.mgmt.automation.models.DscNodeExtensionHandlerAssociationProperty] - :param name_properties_node_configuration_name: Gets or sets the name of the dsc node + :ivar name_properties_node_configuration_name: Gets or sets the name of the dsc node configuration. - :type name_properties_node_configuration_name: str + :vartype name_properties_node_configuration_name: str """ _validation = { @@ -2022,10 +2661,34 @@ def __init__( node_id: Optional[str] = None, etag: Optional[str] = None, total_count: Optional[int] = None, - extension_handler: Optional[List["DscNodeExtensionHandlerAssociationProperty"]] = None, + extension_handler: Optional[List["_models.DscNodeExtensionHandlerAssociationProperty"]] = None, name_properties_node_configuration_name: Optional[str] = None, **kwargs ): + """ + :keyword last_seen: Gets or sets the last seen time of the node. + :paramtype last_seen: ~datetime.datetime + :keyword registration_time: Gets or sets the registration time of the node. + :paramtype registration_time: ~datetime.datetime + :keyword ip: Gets or sets the ip of the node. + :paramtype ip: str + :keyword account_id: Gets or sets the account id of the node. + :paramtype account_id: str + :keyword status: Gets or sets the status of the node. + :paramtype status: str + :keyword node_id: Gets or sets the node id. + :paramtype node_id: str + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword total_count: Gets the total number of records matching filter criteria. + :paramtype total_count: int + :keyword extension_handler: Gets or sets the list of extensionHandler properties for a Node. + :paramtype extension_handler: + list[~azure.mgmt.automation.models.DscNodeExtensionHandlerAssociationProperty] + :keyword name_properties_node_configuration_name: Gets or sets the name of the dsc node + configuration. + :paramtype name_properties_node_configuration_name: str + """ super(DscNode, self).__init__(**kwargs) self.last_seen = last_seen self.registration_time = registration_time @@ -2039,7 +2702,7 @@ def __init__( self.name_properties_node_configuration_name = name_properties_node_configuration_name -class DscNodeConfiguration(Resource): +class DscNodeConfiguration(ProxyResource): """Definition of the dsc node configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2050,19 +2713,19 @@ class DscNodeConfiguration(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param creation_time: Gets or sets creation time. - :type creation_time: ~datetime.datetime - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param source: Source of node configuration. - :type source: str - :param node_count: Number of nodes with this node configuration assigned. - :type node_count: long - :param increment_node_configuration_build: If a new build version of NodeConfiguration is + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar creation_time: Gets or sets creation time. + :vartype creation_time: ~datetime.datetime + :ivar configuration: Gets or sets the configuration of the node. + :vartype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :ivar source: Source of node configuration. + :vartype source: str + :ivar node_count: Number of nodes with this node configuration assigned. + :vartype node_count: long + :ivar increment_node_configuration_build: If a new build version of NodeConfiguration is required. - :type increment_node_configuration_build: bool + :vartype increment_node_configuration_build: bool """ _validation = { @@ -2088,12 +2751,27 @@ def __init__( *, last_modified_time: Optional[datetime.datetime] = None, creation_time: Optional[datetime.datetime] = None, - configuration: Optional["DscConfigurationAssociationProperty"] = None, + configuration: Optional["_models.DscConfigurationAssociationProperty"] = None, source: Optional[str] = None, node_count: Optional[int] = None, increment_node_configuration_build: Optional[bool] = None, **kwargs ): + """ + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword creation_time: Gets or sets creation time. + :paramtype creation_time: ~datetime.datetime + :keyword configuration: Gets or sets the configuration of the node. + :paramtype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :keyword source: Source of node configuration. + :paramtype source: str + :keyword node_count: Number of nodes with this node configuration assigned. + :paramtype node_count: long + :keyword increment_node_configuration_build: If a new build version of NodeConfiguration is + required. + :paramtype increment_node_configuration_build: bool + """ super(DscNodeConfiguration, self).__init__(**kwargs) self.last_modified_time = last_modified_time self.creation_time = creation_time @@ -2106,17 +2784,17 @@ def __init__( class DscNodeConfigurationCreateOrUpdateParameters(msrest.serialization.Model): """The parameters supplied to the create or update node configuration operation. - :param name: Name of the node configuration. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param increment_node_configuration_build: If a new build version of NodeConfiguration is + :ivar name: Name of the node configuration. + :vartype name: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar source: Gets or sets the source. + :vartype source: ~azure.mgmt.automation.models.ContentSource + :ivar configuration: Gets or sets the configuration of the node. + :vartype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :ivar increment_node_configuration_build: If a new build version of NodeConfiguration is required. - :type increment_node_configuration_build: bool + :vartype increment_node_configuration_build: bool """ _attribute_map = { @@ -2132,11 +2810,24 @@ def __init__( *, name: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - source: Optional["ContentSource"] = None, - configuration: Optional["DscConfigurationAssociationProperty"] = None, + source: Optional["_models.ContentSource"] = None, + configuration: Optional["_models.DscConfigurationAssociationProperty"] = None, increment_node_configuration_build: Optional[bool] = None, **kwargs ): + """ + :keyword name: Name of the node configuration. + :paramtype name: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword source: Gets or sets the source. + :paramtype source: ~azure.mgmt.automation.models.ContentSource + :keyword configuration: Gets or sets the configuration of the node. + :paramtype configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty + :keyword increment_node_configuration_build: If a new build version of NodeConfiguration is + required. + :paramtype increment_node_configuration_build: bool + """ super(DscNodeConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.tags = tags @@ -2148,12 +2839,12 @@ def __init__( class DscNodeConfigurationListResult(msrest.serialization.Model): """The response model for the list job operation. - :param value: Gets or sets a list of Dsc node configurations. - :type value: list[~azure.mgmt.automation.models.DscNodeConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets or sets the total rows in query. - :type total_count: int + :ivar value: Gets or sets a list of Dsc node configurations. + :vartype value: list[~azure.mgmt.automation.models.DscNodeConfiguration] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str + :ivar total_count: Gets or sets the total rows in query. + :vartype total_count: int """ _attribute_map = { @@ -2165,11 +2856,19 @@ class DscNodeConfigurationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DscNodeConfiguration"]] = None, + value: Optional[List["_models.DscNodeConfiguration"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of Dsc node configurations. + :paramtype value: list[~azure.mgmt.automation.models.DscNodeConfiguration] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + :keyword total_count: Gets or sets the total rows in query. + :paramtype total_count: int + """ super(DscNodeConfigurationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2179,10 +2878,10 @@ def __init__( class DscNodeExtensionHandlerAssociationProperty(msrest.serialization.Model): """The dsc extensionHandler property associated with the node. - :param name: Gets or sets the name of the extension handler. - :type name: str - :param version: Gets or sets the version of the extension handler. - :type version: str + :ivar name: Gets or sets the name of the extension handler. + :vartype name: str + :ivar version: Gets or sets the version of the extension handler. + :vartype version: str """ _attribute_map = { @@ -2197,6 +2896,12 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the extension handler. + :paramtype name: str + :keyword version: Gets or sets the version of the extension handler. + :paramtype version: str + """ super(DscNodeExtensionHandlerAssociationProperty, self).__init__(**kwargs) self.name = name self.version = version @@ -2205,12 +2910,12 @@ def __init__( class DscNodeListResult(msrest.serialization.Model): """The response model for the list dsc nodes operation. - :param value: Gets or sets a list of dsc nodes. - :type value: list[~azure.mgmt.automation.models.DscNode] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of nodes matching filter criteria. - :type total_count: int + :ivar value: Gets or sets a list of dsc nodes. + :vartype value: list[~azure.mgmt.automation.models.DscNode] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str + :ivar total_count: Gets the total number of nodes matching filter criteria. + :vartype total_count: int """ _attribute_map = { @@ -2222,11 +2927,19 @@ class DscNodeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DscNode"]] = None, + value: Optional[List["_models.DscNode"]] = None, next_link: Optional[str] = None, total_count: Optional[int] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of dsc nodes. + :paramtype value: list[~azure.mgmt.automation.models.DscNode] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + :keyword total_count: Gets the total number of nodes matching filter criteria. + :paramtype total_count: int + """ super(DscNodeListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2236,45 +2949,45 @@ def __init__( class DscNodeReport(msrest.serialization.Model): """Definition of the dsc node report type. - :param end_time: Gets or sets the end time of the node report. - :type end_time: ~datetime.datetime - :param last_modified_time: Gets or sets the lastModifiedTime of the node report. - :type last_modified_time: ~datetime.datetime - :param start_time: Gets or sets the start time of the node report. - :type start_time: ~datetime.datetime - :param type: Gets or sets the type of the node report. - :type type: str - :param report_id: Gets or sets the id of the node report. - :type report_id: str - :param status: Gets or sets the status of the node report. - :type status: str - :param refresh_mode: Gets or sets the refreshMode of the node report. - :type refresh_mode: str - :param reboot_requested: Gets or sets the rebootRequested of the node report. - :type reboot_requested: str - :param report_format_version: Gets or sets the reportFormatVersion of the node report. - :type report_format_version: str - :param configuration_version: Gets or sets the configurationVersion of the node report. - :type configuration_version: str - :param id: Gets or sets the id. - :type id: str - :param errors: Gets or sets the errors for the node report. - :type errors: list[~azure.mgmt.automation.models.DscReportError] - :param resources: Gets or sets the resource for the node report. - :type resources: list[~azure.mgmt.automation.models.DscReportResource] - :param meta_configuration: Gets or sets the metaConfiguration of the node at the time of the + :ivar end_time: Gets or sets the end time of the node report. + :vartype end_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the lastModifiedTime of the node report. + :vartype last_modified_time: ~datetime.datetime + :ivar start_time: Gets or sets the start time of the node report. + :vartype start_time: ~datetime.datetime + :ivar type: Gets or sets the type of the node report. + :vartype type: str + :ivar report_id: Gets or sets the id of the node report. + :vartype report_id: str + :ivar status: Gets or sets the status of the node report. + :vartype status: str + :ivar refresh_mode: Gets or sets the refreshMode of the node report. + :vartype refresh_mode: str + :ivar reboot_requested: Gets or sets the rebootRequested of the node report. + :vartype reboot_requested: str + :ivar report_format_version: Gets or sets the reportFormatVersion of the node report. + :vartype report_format_version: str + :ivar configuration_version: Gets or sets the configurationVersion of the node report. + :vartype configuration_version: str + :ivar id: Gets or sets the id. + :vartype id: str + :ivar errors: Gets or sets the errors for the node report. + :vartype errors: list[~azure.mgmt.automation.models.DscReportError] + :ivar resources: Gets or sets the resource for the node report. + :vartype resources: list[~azure.mgmt.automation.models.DscReportResource] + :ivar meta_configuration: Gets or sets the metaConfiguration of the node at the time of the report. - :type meta_configuration: ~azure.mgmt.automation.models.DscMetaConfiguration - :param host_name: Gets or sets the hostname of the node that sent the report. - :type host_name: str - :param i_pv4_addresses: Gets or sets the IPv4 address of the node that sent the report. - :type i_pv4_addresses: list[str] - :param i_pv6_addresses: Gets or sets the IPv6 address of the node that sent the report. - :type i_pv6_addresses: list[str] - :param number_of_resources: Gets or sets the number of resource in the node report. - :type number_of_resources: int - :param raw_errors: Gets or sets the unparsed errors for the node report. - :type raw_errors: str + :vartype meta_configuration: ~azure.mgmt.automation.models.DscMetaConfiguration + :ivar host_name: Gets or sets the hostname of the node that sent the report. + :vartype host_name: str + :ivar i_pv4_addresses: Gets or sets the IPv4 address of the node that sent the report. + :vartype i_pv4_addresses: list[str] + :ivar i_pv6_addresses: Gets or sets the IPv6 address of the node that sent the report. + :vartype i_pv6_addresses: list[str] + :ivar number_of_resources: Gets or sets the number of resource in the node report. + :vartype number_of_resources: int + :ivar raw_errors: Gets or sets the unparsed errors for the node report. + :vartype raw_errors: str """ _attribute_map = { @@ -2313,9 +3026,9 @@ def __init__( report_format_version: Optional[str] = None, configuration_version: Optional[str] = None, id: Optional[str] = None, - errors: Optional[List["DscReportError"]] = None, - resources: Optional[List["DscReportResource"]] = None, - meta_configuration: Optional["DscMetaConfiguration"] = None, + errors: Optional[List["_models.DscReportError"]] = None, + resources: Optional[List["_models.DscReportResource"]] = None, + meta_configuration: Optional["_models.DscMetaConfiguration"] = None, host_name: Optional[str] = None, i_pv4_addresses: Optional[List[str]] = None, i_pv6_addresses: Optional[List[str]] = None, @@ -2323,6 +3036,47 @@ def __init__( raw_errors: Optional[str] = None, **kwargs ): + """ + :keyword end_time: Gets or sets the end time of the node report. + :paramtype end_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the lastModifiedTime of the node report. + :paramtype last_modified_time: ~datetime.datetime + :keyword start_time: Gets or sets the start time of the node report. + :paramtype start_time: ~datetime.datetime + :keyword type: Gets or sets the type of the node report. + :paramtype type: str + :keyword report_id: Gets or sets the id of the node report. + :paramtype report_id: str + :keyword status: Gets or sets the status of the node report. + :paramtype status: str + :keyword refresh_mode: Gets or sets the refreshMode of the node report. + :paramtype refresh_mode: str + :keyword reboot_requested: Gets or sets the rebootRequested of the node report. + :paramtype reboot_requested: str + :keyword report_format_version: Gets or sets the reportFormatVersion of the node report. + :paramtype report_format_version: str + :keyword configuration_version: Gets or sets the configurationVersion of the node report. + :paramtype configuration_version: str + :keyword id: Gets or sets the id. + :paramtype id: str + :keyword errors: Gets or sets the errors for the node report. + :paramtype errors: list[~azure.mgmt.automation.models.DscReportError] + :keyword resources: Gets or sets the resource for the node report. + :paramtype resources: list[~azure.mgmt.automation.models.DscReportResource] + :keyword meta_configuration: Gets or sets the metaConfiguration of the node at the time of the + report. + :paramtype meta_configuration: ~azure.mgmt.automation.models.DscMetaConfiguration + :keyword host_name: Gets or sets the hostname of the node that sent the report. + :paramtype host_name: str + :keyword i_pv4_addresses: Gets or sets the IPv4 address of the node that sent the report. + :paramtype i_pv4_addresses: list[str] + :keyword i_pv6_addresses: Gets or sets the IPv6 address of the node that sent the report. + :paramtype i_pv6_addresses: list[str] + :keyword number_of_resources: Gets or sets the number of resource in the node report. + :paramtype number_of_resources: int + :keyword raw_errors: Gets or sets the unparsed errors for the node report. + :paramtype raw_errors: str + """ super(DscNodeReport, self).__init__(**kwargs) self.end_time = end_time self.last_modified_time = last_modified_time @@ -2348,10 +3102,10 @@ def __init__( class DscNodeReportListResult(msrest.serialization.Model): """The response model for the list dsc nodes operation. - :param value: Gets or sets a list of dsc node reports. - :type value: list[~azure.mgmt.automation.models.DscNodeReport] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of dsc node reports. + :vartype value: list[~azure.mgmt.automation.models.DscNodeReport] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -2362,10 +3116,16 @@ class DscNodeReportListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DscNodeReport"]] = None, + value: Optional[List["_models.DscNodeReport"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of dsc node reports. + :paramtype value: list[~azure.mgmt.automation.models.DscNodeReport] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(DscNodeReportListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2374,10 +3134,10 @@ def __init__( class DscNodeUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update dsc node operation. - :param node_id: Gets or sets the id of the dsc node. - :type node_id: str - :param properties: - :type properties: ~azure.mgmt.automation.models.DscNodeUpdateParametersProperties + :ivar node_id: Gets or sets the id of the dsc node. + :vartype node_id: str + :ivar properties: + :vartype properties: ~azure.mgmt.automation.models.DscNodeUpdateParametersProperties """ _attribute_map = { @@ -2389,9 +3149,15 @@ def __init__( self, *, node_id: Optional[str] = None, - properties: Optional["DscNodeUpdateParametersProperties"] = None, + properties: Optional["_models.DscNodeUpdateParametersProperties"] = None, **kwargs ): + """ + :keyword node_id: Gets or sets the id of the dsc node. + :paramtype node_id: str + :keyword properties: + :paramtype properties: ~azure.mgmt.automation.models.DscNodeUpdateParametersProperties + """ super(DscNodeUpdateParameters, self).__init__(**kwargs) self.node_id = node_id self.properties = properties @@ -2400,8 +3166,8 @@ def __init__( class DscNodeUpdateParametersProperties(msrest.serialization.Model): """DscNodeUpdateParametersProperties. - :param name: Gets or sets the name of the dsc node configuration. - :type name: str + :ivar name: Gets or sets the name of the dsc node configuration. + :vartype name: str """ _attribute_map = { @@ -2414,6 +3180,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the dsc node configuration. + :paramtype name: str + """ super(DscNodeUpdateParametersProperties, self).__init__(**kwargs) self.name = name @@ -2421,18 +3191,18 @@ def __init__( class DscReportError(msrest.serialization.Model): """Definition of the dsc node report error type. - :param error_source: Gets or sets the source of the error. - :type error_source: str - :param resource_id: Gets or sets the resource ID which generated the error. - :type resource_id: str - :param error_code: Gets or sets the error code. - :type error_code: str - :param error_message: Gets or sets the error message. - :type error_message: str - :param locale: Gets or sets the locale of the error. - :type locale: str - :param error_details: Gets or sets the error details. - :type error_details: str + :ivar error_source: Gets or sets the source of the error. + :vartype error_source: str + :ivar resource_id: Gets or sets the resource ID which generated the error. + :vartype resource_id: str + :ivar error_code: Gets or sets the error code. + :vartype error_code: str + :ivar error_message: Gets or sets the error message. + :vartype error_message: str + :ivar locale: Gets or sets the locale of the error. + :vartype locale: str + :ivar error_details: Gets or sets the error details. + :vartype error_details: str """ _attribute_map = { @@ -2455,6 +3225,20 @@ def __init__( error_details: Optional[str] = None, **kwargs ): + """ + :keyword error_source: Gets or sets the source of the error. + :paramtype error_source: str + :keyword resource_id: Gets or sets the resource ID which generated the error. + :paramtype resource_id: str + :keyword error_code: Gets or sets the error code. + :paramtype error_code: str + :keyword error_message: Gets or sets the error message. + :paramtype error_message: str + :keyword locale: Gets or sets the locale of the error. + :paramtype locale: str + :keyword error_details: Gets or sets the error details. + :paramtype error_details: str + """ super(DscReportError, self).__init__(**kwargs) self.error_source = error_source self.resource_id = resource_id @@ -2467,27 +3251,27 @@ def __init__( class DscReportResource(msrest.serialization.Model): """Definition of the DSC Report Resource. - :param resource_id: Gets or sets the ID of the resource. - :type resource_id: str - :param source_info: Gets or sets the source info of the resource. - :type source_info: str - :param depends_on: Gets or sets the Resource Navigation values for resources the resource + :ivar resource_id: Gets or sets the ID of the resource. + :vartype resource_id: str + :ivar source_info: Gets or sets the source info of the resource. + :vartype source_info: str + :ivar depends_on: Gets or sets the Resource Navigation values for resources the resource depends on. - :type depends_on: list[~azure.mgmt.automation.models.DscReportResourceNavigation] - :param module_name: Gets or sets the module name of the resource. - :type module_name: str - :param module_version: Gets or sets the module version of the resource. - :type module_version: str - :param resource_name: Gets or sets the name of the resource. - :type resource_name: str - :param error: Gets or sets the error of the resource. - :type error: str - :param status: Gets or sets the status of the resource. - :type status: str - :param duration_in_seconds: Gets or sets the duration in seconds for the resource. - :type duration_in_seconds: float - :param start_date: Gets or sets the start date of the resource. - :type start_date: ~datetime.datetime + :vartype depends_on: list[~azure.mgmt.automation.models.DscReportResourceNavigation] + :ivar module_name: Gets or sets the module name of the resource. + :vartype module_name: str + :ivar module_version: Gets or sets the module version of the resource. + :vartype module_version: str + :ivar resource_name: Gets or sets the name of the resource. + :vartype resource_name: str + :ivar error: Gets or sets the error of the resource. + :vartype error: str + :ivar status: Gets or sets the status of the resource. + :vartype status: str + :ivar duration_in_seconds: Gets or sets the duration in seconds for the resource. + :vartype duration_in_seconds: float + :ivar start_date: Gets or sets the start date of the resource. + :vartype start_date: ~datetime.datetime """ _attribute_map = { @@ -2508,7 +3292,7 @@ def __init__( *, resource_id: Optional[str] = None, source_info: Optional[str] = None, - depends_on: Optional[List["DscReportResourceNavigation"]] = None, + depends_on: Optional[List["_models.DscReportResourceNavigation"]] = None, module_name: Optional[str] = None, module_version: Optional[str] = None, resource_name: Optional[str] = None, @@ -2518,6 +3302,29 @@ def __init__( start_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword resource_id: Gets or sets the ID of the resource. + :paramtype resource_id: str + :keyword source_info: Gets or sets the source info of the resource. + :paramtype source_info: str + :keyword depends_on: Gets or sets the Resource Navigation values for resources the resource + depends on. + :paramtype depends_on: list[~azure.mgmt.automation.models.DscReportResourceNavigation] + :keyword module_name: Gets or sets the module name of the resource. + :paramtype module_name: str + :keyword module_version: Gets or sets the module version of the resource. + :paramtype module_version: str + :keyword resource_name: Gets or sets the name of the resource. + :paramtype resource_name: str + :keyword error: Gets or sets the error of the resource. + :paramtype error: str + :keyword status: Gets or sets the status of the resource. + :paramtype status: str + :keyword duration_in_seconds: Gets or sets the duration in seconds for the resource. + :paramtype duration_in_seconds: float + :keyword start_date: Gets or sets the start date of the resource. + :paramtype start_date: ~datetime.datetime + """ super(DscReportResource, self).__init__(**kwargs) self.resource_id = resource_id self.source_info = source_info @@ -2534,8 +3341,8 @@ def __init__( class DscReportResourceNavigation(msrest.serialization.Model): """Navigation for DSC Report Resource. - :param resource_id: Gets or sets the ID of the resource to navigate to. - :type resource_id: str + :ivar resource_id: Gets or sets the ID of the resource to navigate to. + :vartype resource_id: str """ _attribute_map = { @@ -2548,17 +3355,91 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: Gets or sets the ID of the resource to navigate to. + :paramtype resource_id: str + """ super(DscReportResourceNavigation, self).__init__(**kwargs) self.resource_id = resource_id +class EncryptionProperties(msrest.serialization.Model): + """The encryption settings for automation account. + + :ivar key_vault_properties: Key vault properties. + :vartype key_vault_properties: ~azure.mgmt.automation.models.KeyVaultProperties + :ivar key_source: Encryption Key Source. Known values are: "Microsoft.Automation", + "Microsoft.Keyvault". + :vartype key_source: str or ~azure.mgmt.automation.models.EncryptionKeySourceType + :ivar identity: User identity used for CMK. + :vartype identity: ~azure.mgmt.automation.models.EncryptionPropertiesIdentity + """ + + _attribute_map = { + 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, + 'key_source': {'key': 'keySource', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'EncryptionPropertiesIdentity'}, + } + + def __init__( + self, + *, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + key_source: Optional[Union[str, "_models.EncryptionKeySourceType"]] = None, + identity: Optional["_models.EncryptionPropertiesIdentity"] = None, + **kwargs + ): + """ + :keyword key_vault_properties: Key vault properties. + :paramtype key_vault_properties: ~azure.mgmt.automation.models.KeyVaultProperties + :keyword key_source: Encryption Key Source. Known values are: "Microsoft.Automation", + "Microsoft.Keyvault". + :paramtype key_source: str or ~azure.mgmt.automation.models.EncryptionKeySourceType + :keyword identity: User identity used for CMK. + :paramtype identity: ~azure.mgmt.automation.models.EncryptionPropertiesIdentity + """ + super(EncryptionProperties, self).__init__(**kwargs) + self.key_vault_properties = key_vault_properties + self.key_source = key_source + self.identity = identity + + +class EncryptionPropertiesIdentity(msrest.serialization.Model): + """User identity used for CMK. + + :ivar user_assigned_identity: The user identity used for CMK. It will be an ARM resource id in + the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identity: any + """ + + _attribute_map = { + 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'object'}, + } + + def __init__( + self, + *, + user_assigned_identity: Optional[Any] = None, + **kwargs + ): + """ + :keyword user_assigned_identity: The user identity used for CMK. It will be an ARM resource id + in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identity: any + """ + super(EncryptionPropertiesIdentity, self).__init__(**kwargs) + self.user_assigned_identity = user_assigned_identity + + class ErrorResponse(msrest.serialization.Model): """Error response of an operation failure. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -2573,6 +3454,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -2583,12 +3470,12 @@ class FieldDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. - :type is_encrypted: bool - :param is_optional: Gets or sets the isOptional flag of the connection field definition. - :type is_optional: bool - :param type: Required. Gets or sets the type of the connection field definition. - :type type: str + :ivar is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. + :vartype is_encrypted: bool + :ivar is_optional: Gets or sets the isOptional flag of the connection field definition. + :vartype is_optional: bool + :ivar type: Required. Gets or sets the type of the connection field definition. + :vartype type: str """ _validation = { @@ -2609,69 +3496,200 @@ def __init__( is_optional: Optional[bool] = None, **kwargs ): + """ + :keyword is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. + :paramtype is_encrypted: bool + :keyword is_optional: Gets or sets the isOptional flag of the connection field definition. + :paramtype is_optional: bool + :keyword type: Required. Gets or sets the type of the connection field definition. + :paramtype type: str + """ super(FieldDefinition, self).__init__(**kwargs) self.is_encrypted = is_encrypted self.is_optional = is_optional self.type = type -class HybridRunbookWorker(msrest.serialization.Model): +class GraphicalRunbookContent(msrest.serialization.Model): + """Graphical Runbook Content. + + :ivar raw_content: Raw graphical Runbook content. + :vartype raw_content: ~azure.mgmt.automation.models.RawGraphicalRunbookContent + :ivar graph_runbook_json: Graphical Runbook content as JSON. + :vartype graph_runbook_json: str + """ + + _attribute_map = { + 'raw_content': {'key': 'rawContent', 'type': 'RawGraphicalRunbookContent'}, + 'graph_runbook_json': {'key': 'graphRunbookJson', 'type': 'str'}, + } + + def __init__( + self, + *, + raw_content: Optional["_models.RawGraphicalRunbookContent"] = None, + graph_runbook_json: Optional[str] = None, + **kwargs + ): + """ + :keyword raw_content: Raw graphical Runbook content. + :paramtype raw_content: ~azure.mgmt.automation.models.RawGraphicalRunbookContent + :keyword graph_runbook_json: Graphical Runbook content as JSON. + :paramtype graph_runbook_json: str + """ + super(GraphicalRunbookContent, self).__init__(**kwargs) + self.raw_content = raw_content + self.graph_runbook_json = graph_runbook_json + + +class HybridRunbookWorker(Resource): """Definition of hybrid runbook worker. - :param name: Gets or sets the worker machine name. - :type name: str - :param ip: Gets or sets the assigned machine IP address. - :type ip: str - :param registration_time: Gets or sets the registration time of the worker machine. - :type registration_time: ~datetime.datetime - :param last_seen_date_time: Last Heartbeat from the Worker. - :type last_seen_date_time: ~datetime.datetime + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar system_data: Resource system metadata. + :vartype system_data: ~azure.mgmt.automation.models.SystemData + :ivar ip: Gets or sets the assigned machine IP address. + :vartype ip: str + :ivar registered_date_time: Gets or sets the registration time of the worker machine. + :vartype registered_date_time: ~datetime.datetime + :ivar last_seen_date_time: Last Heartbeat from the Worker. + :vartype last_seen_date_time: ~datetime.datetime + :ivar vm_resource_id: Azure Resource Manager Id for a virtual machine. + :vartype vm_resource_id: str + :ivar worker_type: Type of the HybridWorker. Known values are: "HybridV1", "HybridV2". + :vartype worker_type: str or ~azure.mgmt.automation.models.WorkerType + :ivar worker_name: Name of the HybridWorker. + :vartype worker_name: str """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, - 'registration_time': {'key': 'registrationTime', 'type': 'iso-8601'}, - 'last_seen_date_time': {'key': 'lastSeenDateTime', 'type': 'iso-8601'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'ip': {'key': 'properties.ip', 'type': 'str'}, + 'registered_date_time': {'key': 'properties.registeredDateTime', 'type': 'iso-8601'}, + 'last_seen_date_time': {'key': 'properties.lastSeenDateTime', 'type': 'iso-8601'}, + 'vm_resource_id': {'key': 'properties.vmResourceId', 'type': 'str'}, + 'worker_type': {'key': 'properties.workerType', 'type': 'str'}, + 'worker_name': {'key': 'properties.workerName', 'type': 'str'}, } def __init__( self, *, - name: Optional[str] = None, ip: Optional[str] = None, - registration_time: Optional[datetime.datetime] = None, + registered_date_time: Optional[datetime.datetime] = None, last_seen_date_time: Optional[datetime.datetime] = None, - **kwargs - ): + vm_resource_id: Optional[str] = None, + worker_type: Optional[Union[str, "_models.WorkerType"]] = None, + worker_name: Optional[str] = None, + **kwargs + ): + """ + :keyword ip: Gets or sets the assigned machine IP address. + :paramtype ip: str + :keyword registered_date_time: Gets or sets the registration time of the worker machine. + :paramtype registered_date_time: ~datetime.datetime + :keyword last_seen_date_time: Last Heartbeat from the Worker. + :paramtype last_seen_date_time: ~datetime.datetime + :keyword vm_resource_id: Azure Resource Manager Id for a virtual machine. + :paramtype vm_resource_id: str + :keyword worker_type: Type of the HybridWorker. Known values are: "HybridV1", "HybridV2". + :paramtype worker_type: str or ~azure.mgmt.automation.models.WorkerType + :keyword worker_name: Name of the HybridWorker. + :paramtype worker_name: str + """ super(HybridRunbookWorker, self).__init__(**kwargs) - self.name = name + self.system_data = None self.ip = ip - self.registration_time = registration_time + self.registered_date_time = registered_date_time self.last_seen_date_time = last_seen_date_time + self.vm_resource_id = vm_resource_id + self.worker_type = worker_type + self.worker_name = worker_name + + +class HybridRunbookWorkerCreateParameters(msrest.serialization.Model): + """The parameters supplied to the create hybrid runbook worker operation. + + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar vm_resource_id: Azure Resource Manager Id for a virtual machine. + :vartype vm_resource_id: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'vm_resource_id': {'key': 'properties.vmResourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + vm_resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the resource. + :paramtype name: str + :keyword vm_resource_id: Azure Resource Manager Id for a virtual machine. + :paramtype vm_resource_id: str + """ + super(HybridRunbookWorkerCreateParameters, self).__init__(**kwargs) + self.name = name + self.vm_resource_id = vm_resource_id class HybridRunbookWorkerGroup(msrest.serialization.Model): """Definition of hybrid runbook worker group. - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the name of the group. - :type name: str - :param hybrid_runbook_workers: Gets or sets the list of hybrid runbook workers. - :type hybrid_runbook_workers: list[~azure.mgmt.automation.models.HybridRunbookWorker] - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty - :param group_type: Type of the HybridWorkerGroup. Possible values include: "User", "System". - :type group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Gets or sets the id of the resource. + :vartype id: str + :ivar name: Gets or sets the name of the group. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar hybrid_runbook_workers: Gets or sets the list of hybrid runbook workers. + :vartype hybrid_runbook_workers: list[~azure.mgmt.automation.models.HybridRunbookWorkerLegacy] + :ivar credential: Sets the credential of a worker group. + :vartype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + :ivar group_type: Type of the HybridWorkerGroup. Known values are: "User", "System". + :vartype group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum + :ivar system_data: Resource system metadata. + :vartype system_data: ~azure.mgmt.automation.models.SystemData """ + _validation = { + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'hybrid_runbook_workers': {'key': 'hybridRunbookWorkers', 'type': '[HybridRunbookWorker]'}, + 'type': {'key': 'type', 'type': 'str'}, + 'hybrid_runbook_workers': {'key': 'hybridRunbookWorkers', 'type': '[HybridRunbookWorkerLegacy]'}, 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, 'group_type': {'key': 'groupType', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -2679,26 +3697,66 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - hybrid_runbook_workers: Optional[List["HybridRunbookWorker"]] = None, - credential: Optional["RunAsCredentialAssociationProperty"] = None, - group_type: Optional[Union[str, "GroupTypeEnum"]] = None, - **kwargs - ): + hybrid_runbook_workers: Optional[List["_models.HybridRunbookWorkerLegacy"]] = None, + credential: Optional["_models.RunAsCredentialAssociationProperty"] = None, + group_type: Optional[Union[str, "_models.GroupTypeEnum"]] = None, + **kwargs + ): + """ + :keyword id: Gets or sets the id of the resource. + :paramtype id: str + :keyword name: Gets or sets the name of the group. + :paramtype name: str + :keyword hybrid_runbook_workers: Gets or sets the list of hybrid runbook workers. + :paramtype hybrid_runbook_workers: + list[~azure.mgmt.automation.models.HybridRunbookWorkerLegacy] + :keyword credential: Sets the credential of a worker group. + :paramtype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + :keyword group_type: Type of the HybridWorkerGroup. Known values are: "User", "System". + :paramtype group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum + """ super(HybridRunbookWorkerGroup, self).__init__(**kwargs) self.id = id self.name = name + self.type = None self.hybrid_runbook_workers = hybrid_runbook_workers self.credential = credential self.group_type = group_type + self.system_data = None + + +class HybridRunbookWorkerGroupCreateOrUpdateParameters(msrest.serialization.Model): + """The parameters supplied to the create or update hybrid runbook worker group operation. + + :ivar credential: Sets the credential of a worker group. + :vartype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + """ + + _attribute_map = { + 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, + } + + def __init__( + self, + *, + credential: Optional["_models.RunAsCredentialAssociationProperty"] = None, + **kwargs + ): + """ + :keyword credential: Sets the credential of a worker group. + :paramtype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + """ + super(HybridRunbookWorkerGroupCreateOrUpdateParameters, self).__init__(**kwargs) + self.credential = credential class HybridRunbookWorkerGroupsListResult(msrest.serialization.Model): """The response model for the list hybrid runbook worker groups. - :param value: Gets or sets a list of hybrid runbook worker groups. - :type value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of hybrid runbook worker groups. + :vartype value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -2709,10 +3767,16 @@ class HybridRunbookWorkerGroupsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["HybridRunbookWorkerGroup"]] = None, + value: Optional[List["_models.HybridRunbookWorkerGroup"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of hybrid runbook worker groups. + :paramtype value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(HybridRunbookWorkerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2721,8 +3785,8 @@ def __init__( class HybridRunbookWorkerGroupUpdateParameters(msrest.serialization.Model): """Parameters supplied to the update operation. - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + :ivar credential: Sets the credential of a worker group. + :vartype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty """ _attribute_map = { @@ -2732,14 +3796,176 @@ class HybridRunbookWorkerGroupUpdateParameters(msrest.serialization.Model): def __init__( self, *, - credential: Optional["RunAsCredentialAssociationProperty"] = None, + credential: Optional["_models.RunAsCredentialAssociationProperty"] = None, **kwargs ): + """ + :keyword credential: Sets the credential of a worker group. + :paramtype credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty + """ super(HybridRunbookWorkerGroupUpdateParameters, self).__init__(**kwargs) self.credential = credential -class Job(Resource): +class HybridRunbookWorkerLegacy(msrest.serialization.Model): + """Definition of hybrid runbook worker Legacy. + + :ivar name: Gets or sets the worker machine name. + :vartype name: str + :ivar ip: Gets or sets the assigned machine IP address. + :vartype ip: str + :ivar registration_time: Gets or sets the registration time of the worker machine. + :vartype registration_time: ~datetime.datetime + :ivar last_seen_date_time: Last Heartbeat from the Worker. + :vartype last_seen_date_time: ~datetime.datetime + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'ip': {'key': 'ip', 'type': 'str'}, + 'registration_time': {'key': 'registrationTime', 'type': 'iso-8601'}, + 'last_seen_date_time': {'key': 'lastSeenDateTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + ip: Optional[str] = None, + registration_time: Optional[datetime.datetime] = None, + last_seen_date_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the worker machine name. + :paramtype name: str + :keyword ip: Gets or sets the assigned machine IP address. + :paramtype ip: str + :keyword registration_time: Gets or sets the registration time of the worker machine. + :paramtype registration_time: ~datetime.datetime + :keyword last_seen_date_time: Last Heartbeat from the Worker. + :paramtype last_seen_date_time: ~datetime.datetime + """ + super(HybridRunbookWorkerLegacy, self).__init__(**kwargs) + self.name = name + self.ip = ip + self.registration_time = registration_time + self.last_seen_date_time = last_seen_date_time + + +class HybridRunbookWorkerMoveParameters(msrest.serialization.Model): + """Parameters supplied to move hybrid worker operation. + + :ivar hybrid_runbook_worker_group_name: Gets or sets the target hybrid runbook worker group. + :vartype hybrid_runbook_worker_group_name: str + """ + + _attribute_map = { + 'hybrid_runbook_worker_group_name': {'key': 'hybridRunbookWorkerGroupName', 'type': 'str'}, + } + + def __init__( + self, + *, + hybrid_runbook_worker_group_name: Optional[str] = None, + **kwargs + ): + """ + :keyword hybrid_runbook_worker_group_name: Gets or sets the target hybrid runbook worker group. + :paramtype hybrid_runbook_worker_group_name: str + """ + super(HybridRunbookWorkerMoveParameters, self).__init__(**kwargs) + self.hybrid_runbook_worker_group_name = hybrid_runbook_worker_group_name + + +class HybridRunbookWorkersListResult(msrest.serialization.Model): + """The response model for the list hybrid runbook workers. + + :ivar value: Gets or sets a list of hybrid runbook workers. + :vartype value: list[~azure.mgmt.automation.models.HybridRunbookWorker] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[HybridRunbookWorker]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.HybridRunbookWorker"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets a list of hybrid runbook workers. + :paramtype value: list[~azure.mgmt.automation.models.HybridRunbookWorker] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ + super(HybridRunbookWorkersListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.automation.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.automation.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.automation.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.automation.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class Job(ProxyResource): """Definition of the job. Variables are only populated by the server, and will be ignored when sending a request. @@ -2750,38 +3976,38 @@ class Job(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param started_by: Gets or sets the job started by. - :type started_by: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be + :ivar runbook: Gets or sets the runbook. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar started_by: Gets or sets the job started by. + :vartype started_by: str + :ivar run_on: Gets or sets the runOn which specifies the group name where the job is to be executed. - :type run_on: str - :param job_id: Gets or sets the id of the job. - :type job_id: str - :param creation_time: Gets or sets the creation time of the job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str - :param start_time: Gets or sets the start time of the job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param provisioning_state: The current provisioning state of the job. Possible values include: + :vartype run_on: str + :ivar job_id: Gets or sets the id of the job. + :vartype job_id: str + :ivar creation_time: Gets or sets the creation time of the job. + :vartype creation_time: ~datetime.datetime + :ivar status: Gets or sets the status of the job. Known values are: "New", "Activating", + "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", + "Suspending", "Stopping", "Resuming", "Removing". + :vartype status: str or ~azure.mgmt.automation.models.JobStatus + :ivar status_details: Gets or sets the status details of the job. + :vartype status_details: str + :ivar start_time: Gets or sets the start time of the job. + :vartype start_time: ~datetime.datetime + :ivar end_time: Gets or sets the end time of the job. + :vartype end_time: ~datetime.datetime + :ivar exception: Gets or sets the exception of the job. + :vartype exception: str + :ivar last_modified_time: Gets or sets the last modified time of the job. + :vartype last_modified_time: ~datetime.datetime + :ivar last_status_modified_time: Gets or sets the last status modified time of the job. + :vartype last_status_modified_time: ~datetime.datetime + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] + :ivar provisioning_state: The current provisioning state of the job. Known values are: "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState + :vartype provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState """ _validation = { @@ -2813,12 +4039,12 @@ class Job(Resource): def __init__( self, *, - runbook: Optional["RunbookAssociationProperty"] = None, + runbook: Optional["_models.RunbookAssociationProperty"] = None, started_by: Optional[str] = None, run_on: Optional[str] = None, job_id: Optional[str] = None, creation_time: Optional[datetime.datetime] = None, - status: Optional[Union[str, "JobStatus"]] = None, + status: Optional[Union[str, "_models.JobStatus"]] = None, status_details: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, @@ -2826,9 +4052,43 @@ def __init__( last_modified_time: Optional[datetime.datetime] = None, last_status_modified_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "JobProvisioningState"]] = None, - **kwargs - ): + provisioning_state: Optional[Union[str, "_models.JobProvisioningState"]] = None, + **kwargs + ): + """ + :keyword runbook: Gets or sets the runbook. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword started_by: Gets or sets the job started by. + :paramtype started_by: str + :keyword run_on: Gets or sets the runOn which specifies the group name where the job is to be + executed. + :paramtype run_on: str + :keyword job_id: Gets or sets the id of the job. + :paramtype job_id: str + :keyword creation_time: Gets or sets the creation time of the job. + :paramtype creation_time: ~datetime.datetime + :keyword status: Gets or sets the status of the job. Known values are: "New", "Activating", + "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", + "Suspending", "Stopping", "Resuming", "Removing". + :paramtype status: str or ~azure.mgmt.automation.models.JobStatus + :keyword status_details: Gets or sets the status details of the job. + :paramtype status_details: str + :keyword start_time: Gets or sets the start time of the job. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Gets or sets the end time of the job. + :paramtype end_time: ~datetime.datetime + :keyword exception: Gets or sets the exception of the job. + :paramtype exception: str + :keyword last_modified_time: Gets or sets the last modified time of the job. + :paramtype last_modified_time: ~datetime.datetime + :keyword last_status_modified_time: Gets or sets the last status modified time of the job. + :paramtype last_status_modified_time: ~datetime.datetime + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + :keyword provisioning_state: The current provisioning state of the job. Known values are: + "Failed", "Succeeded", "Suspended", "Processing". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState + """ super(Job, self).__init__(**kwargs) self.runbook = runbook self.started_by = started_by @@ -2846,7 +4106,7 @@ def __init__( self.provisioning_state = provisioning_state -class JobCollectionItem(Resource): +class JobCollectionItem(ProxyResource): """Job collection item properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2863,7 +4123,7 @@ class JobCollectionItem(Resource): :vartype job_id: str :ivar creation_time: The creation time of the job. :vartype creation_time: ~datetime.datetime - :ivar status: The status of the job. Possible values include: "New", "Activating", "Running", + :ivar status: The status of the job. Known values are: "New", "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". :vartype status: str or ~azure.mgmt.automation.models.JobStatus @@ -2875,8 +4135,8 @@ class JobCollectionItem(Resource): :vartype last_modified_time: ~datetime.datetime :ivar provisioning_state: The provisioning state of a resource. :vartype provisioning_state: str - :param run_on: Specifies the runOn group name where the job was executed. - :type run_on: str + :ivar run_on: Specifies the runOn group name where the job was executed. + :vartype run_on: str """ _validation = { @@ -2914,6 +4174,10 @@ def __init__( run_on: Optional[str] = None, **kwargs ): + """ + :keyword run_on: Specifies the runOn group name where the job was executed. + :paramtype run_on: str + """ super(JobCollectionItem, self).__init__(**kwargs) self.runbook = None self.job_id = None @@ -2929,13 +4193,13 @@ def __init__( class JobCreateParameters(msrest.serialization.Model): """The parameters supplied to the create job operation. - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be + :ivar runbook: Gets or sets the runbook. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] + :ivar run_on: Gets or sets the runOn which specifies the group name where the job is to be executed. - :type run_on: str + :vartype run_on: str """ _attribute_map = { @@ -2947,11 +4211,20 @@ class JobCreateParameters(msrest.serialization.Model): def __init__( self, *, - runbook: Optional["RunbookAssociationProperty"] = None, + runbook: Optional["_models.RunbookAssociationProperty"] = None, parameters: Optional[Dict[str, str]] = None, run_on: Optional[str] = None, **kwargs ): + """ + :keyword runbook: Gets or sets the runbook. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + :keyword run_on: Gets or sets the runOn which specifies the group name where the job is to be + executed. + :paramtype run_on: str + """ super(JobCreateParameters, self).__init__(**kwargs) self.runbook = runbook self.parameters = parameters @@ -2963,8 +4236,8 @@ class JobListResultV2(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of jobs. - :type value: list[~azure.mgmt.automation.models.JobCollectionItem] + :ivar value: List of jobs. + :vartype value: list[~azure.mgmt.automation.models.JobCollectionItem] :ivar next_link: The link to the next page. :vartype next_link: str """ @@ -2981,9 +4254,13 @@ class JobListResultV2(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["JobCollectionItem"]] = None, + value: Optional[List["_models.JobCollectionItem"]] = None, **kwargs ): + """ + :keyword value: List of jobs. + :paramtype value: list[~azure.mgmt.automation.models.JobCollectionItem] + """ super(JobListResultV2, self).__init__(**kwargs) self.value = value self.next_link = None @@ -3010,6 +4287,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobNavigation, self).__init__(**kwargs) self.id = None @@ -3025,16 +4304,16 @@ class JobSchedule(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param job_schedule_id: Gets or sets the id of job schedule. - :type job_schedule_id: str - :param schedule: Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job schedule. - :type parameters: dict[str, str] + :ivar job_schedule_id: Gets or sets the id of job schedule. + :vartype job_schedule_id: str + :ivar schedule: Gets or sets the schedule. + :vartype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty + :ivar runbook: Gets or sets the runbook. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar run_on: Gets or sets the hybrid worker group that the scheduled job should run on. + :vartype run_on: str + :ivar parameters: Gets or sets the parameters of the job schedule. + :vartype parameters: dict[str, str] """ _validation = { @@ -3058,12 +4337,24 @@ def __init__( self, *, job_schedule_id: Optional[str] = None, - schedule: Optional["ScheduleAssociationProperty"] = None, - runbook: Optional["RunbookAssociationProperty"] = None, + schedule: Optional["_models.ScheduleAssociationProperty"] = None, + runbook: Optional["_models.RunbookAssociationProperty"] = None, run_on: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword job_schedule_id: Gets or sets the id of job schedule. + :paramtype job_schedule_id: str + :keyword schedule: Gets or sets the schedule. + :paramtype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty + :keyword runbook: Gets or sets the runbook. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword run_on: Gets or sets the hybrid worker group that the scheduled job should run on. + :paramtype run_on: str + :keyword parameters: Gets or sets the parameters of the job schedule. + :paramtype parameters: dict[str, str] + """ super(JobSchedule, self).__init__(**kwargs) self.id = None self.name = None @@ -3080,14 +4371,14 @@ class JobScheduleCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param schedule: Required. Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Required. Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets a list of job properties. - :type parameters: dict[str, str] + :ivar schedule: Required. Gets or sets the schedule. + :vartype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty + :ivar runbook: Required. Gets or sets the runbook. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar run_on: Gets or sets the hybrid worker group that the scheduled job should run on. + :vartype run_on: str + :ivar parameters: Gets or sets a list of job properties. + :vartype parameters: dict[str, str] """ _validation = { @@ -3105,12 +4396,22 @@ class JobScheduleCreateParameters(msrest.serialization.Model): def __init__( self, *, - schedule: "ScheduleAssociationProperty", - runbook: "RunbookAssociationProperty", + schedule: "_models.ScheduleAssociationProperty", + runbook: "_models.RunbookAssociationProperty", run_on: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword schedule: Required. Gets or sets the schedule. + :paramtype schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty + :keyword runbook: Required. Gets or sets the runbook. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword run_on: Gets or sets the hybrid worker group that the scheduled job should run on. + :paramtype run_on: str + :keyword parameters: Gets or sets a list of job properties. + :paramtype parameters: dict[str, str] + """ super(JobScheduleCreateParameters, self).__init__(**kwargs) self.schedule = schedule self.runbook = runbook @@ -3121,10 +4422,10 @@ def __init__( class JobScheduleListResult(msrest.serialization.Model): """The response model for the list job schedule operation. - :param value: Gets or sets a list of job schedules. - :type value: list[~azure.mgmt.automation.models.JobSchedule] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of job schedules. + :vartype value: list[~azure.mgmt.automation.models.JobSchedule] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -3135,10 +4436,16 @@ class JobScheduleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["JobSchedule"]] = None, + value: Optional[List["_models.JobSchedule"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of job schedules. + :paramtype value: list[~azure.mgmt.automation.models.JobSchedule] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(JobScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -3147,21 +4454,21 @@ def __init__( class JobStream(msrest.serialization.Model): """Definition of the job stream. - :param id: Gets or sets the id of the resource. - :type id: str - :param job_stream_id: Gets or sets the id of the job stream. - :type job_stream_id: str - :param time: Gets or sets the creation time of the job. - :type time: ~datetime.datetime - :param stream_type: Gets or sets the stream type. Possible values include: "Progress", - "Output", "Warning", "Error", "Debug", "Verbose", "Any". - :type stream_type: str or ~azure.mgmt.automation.models.JobStreamType - :param stream_text: Gets or sets the stream text. - :type stream_text: str - :param summary: Gets or sets the summary. - :type summary: str - :param value: Gets or sets the values of the job stream. - :type value: dict[str, object] + :ivar id: Gets or sets the id of the resource. + :vartype id: str + :ivar job_stream_id: Gets or sets the id of the job stream. + :vartype job_stream_id: str + :ivar time: Gets or sets the creation time of the job. + :vartype time: ~datetime.datetime + :ivar stream_type: Gets or sets the stream type. Known values are: "Progress", "Output", + "Warning", "Error", "Debug", "Verbose", "Any". + :vartype stream_type: str or ~azure.mgmt.automation.models.JobStreamType + :ivar stream_text: Gets or sets the stream text. + :vartype stream_text: str + :ivar summary: Gets or sets the summary. + :vartype summary: str + :ivar value: Gets or sets the values of the job stream. + :vartype value: dict[str, any] """ _attribute_map = { @@ -3180,12 +4487,29 @@ def __init__( id: Optional[str] = None, job_stream_id: Optional[str] = None, time: Optional[datetime.datetime] = None, - stream_type: Optional[Union[str, "JobStreamType"]] = None, + stream_type: Optional[Union[str, "_models.JobStreamType"]] = None, stream_text: Optional[str] = None, summary: Optional[str] = None, - value: Optional[Dict[str, object]] = None, - **kwargs - ): + value: Optional[Dict[str, Any]] = None, + **kwargs + ): + """ + :keyword id: Gets or sets the id of the resource. + :paramtype id: str + :keyword job_stream_id: Gets or sets the id of the job stream. + :paramtype job_stream_id: str + :keyword time: Gets or sets the creation time of the job. + :paramtype time: ~datetime.datetime + :keyword stream_type: Gets or sets the stream type. Known values are: "Progress", "Output", + "Warning", "Error", "Debug", "Verbose", "Any". + :paramtype stream_type: str or ~azure.mgmt.automation.models.JobStreamType + :keyword stream_text: Gets or sets the stream text. + :paramtype stream_text: str + :keyword summary: Gets or sets the summary. + :paramtype summary: str + :keyword value: Gets or sets the values of the job stream. + :paramtype value: dict[str, any] + """ super(JobStream, self).__init__(**kwargs) self.id = id self.job_stream_id = job_stream_id @@ -3199,10 +4523,10 @@ def __init__( class JobStreamListResult(msrest.serialization.Model): """The response model for the list job stream operation. - :param value: A list of job streams. - :type value: list[~azure.mgmt.automation.models.JobStream] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: A list of job streams. + :vartype value: list[~azure.mgmt.automation.models.JobStream] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -3213,10 +4537,16 @@ class JobStreamListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["JobStream"]] = None, + value: Optional[List["_models.JobStream"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A list of job streams. + :paramtype value: list[~azure.mgmt.automation.models.JobStream] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(JobStreamListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -3227,9 +4557,9 @@ class Key(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar key_name: Automation key name. Possible values include: "Primary", "Secondary". + :ivar key_name: Automation key name. Known values are: "Primary", "Secondary". :vartype key_name: str or ~azure.mgmt.automation.models.AutomationKeyName - :ivar permissions: Automation key permissions. Possible values include: "Read", "Full". + :ivar permissions: Automation key permissions. Known values are: "Read", "Full". :vartype permissions: str or ~azure.mgmt.automation.models.AutomationKeyPermissions :ivar value: Value of the Automation Key used for registration. :vartype value: str @@ -3251,6 +4581,8 @@ def __init__( self, **kwargs ): + """ + """ super(Key, self).__init__(**kwargs) self.key_name = None self.permissions = None @@ -3260,8 +4592,8 @@ def __init__( class KeyListResult(msrest.serialization.Model): """KeyListResult. - :param keys: Lists the automation keys. - :type keys: list[~azure.mgmt.automation.models.Key] + :ivar keys: Lists the automation keys. + :vartype keys: list[~azure.mgmt.automation.models.Key] """ _attribute_map = { @@ -3271,13 +4603,56 @@ class KeyListResult(msrest.serialization.Model): def __init__( self, *, - keys: Optional[List["Key"]] = None, + keys: Optional[List["_models.Key"]] = None, **kwargs ): + """ + :keyword keys: Lists the automation keys. + :paramtype keys: list[~azure.mgmt.automation.models.Key] + """ super(KeyListResult, self).__init__(**kwargs) self.keys = keys +class KeyVaultProperties(msrest.serialization.Model): + """Settings concerning key vault encryption for a configuration store. + + :ivar keyvault_uri: The URI of the key vault key used to encrypt data. + :vartype keyvault_uri: str + :ivar key_name: The name of key used to encrypt data. + :vartype key_name: str + :ivar key_version: The key version of the key used to encrypt data. + :vartype key_version: str + """ + + _attribute_map = { + 'keyvault_uri': {'key': 'keyvaultUri', 'type': 'str'}, + 'key_name': {'key': 'keyName', 'type': 'str'}, + 'key_version': {'key': 'keyVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + keyvault_uri: Optional[str] = None, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + **kwargs + ): + """ + :keyword keyvault_uri: The URI of the key vault key used to encrypt data. + :paramtype keyvault_uri: str + :keyword key_name: The name of key used to encrypt data. + :paramtype key_name: str + :keyword key_version: The key version of the key used to encrypt data. + :paramtype key_version: str + """ + super(KeyVaultProperties, self).__init__(**kwargs) + self.keyvault_uri = keyvault_uri + self.key_name = key_name + self.key_version = key_version + + class LinkedWorkspace(msrest.serialization.Model): """Definition of the linked workspace. @@ -3299,6 +4674,8 @@ def __init__( self, **kwargs ): + """ + """ super(LinkedWorkspace, self).__init__(**kwargs) self.id = None @@ -3306,15 +4683,16 @@ def __init__( class LinuxProperties(msrest.serialization.Model): """Linux specific update configuration. - :param included_package_classifications: Update classifications included in the software update - configuration. Possible values include: "Unclassified", "Critical", "Security", "Other". - :type included_package_classifications: str or ~azure.mgmt.automation.models.LinuxUpdateClasses - :param excluded_package_name_masks: packages excluded from the software update configuration. - :type excluded_package_name_masks: list[str] - :param included_package_name_masks: packages included from the software update configuration. - :type included_package_name_masks: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str + :ivar included_package_classifications: Update classifications included in the software update + configuration. Known values are: "Unclassified", "Critical", "Security", "Other". + :vartype included_package_classifications: str or + ~azure.mgmt.automation.models.LinuxUpdateClasses + :ivar excluded_package_name_masks: packages excluded from the software update configuration. + :vartype excluded_package_name_masks: list[str] + :ivar included_package_name_masks: packages included from the software update configuration. + :vartype included_package_name_masks: list[str] + :ivar reboot_setting: Reboot setting for the software update configuration. + :vartype reboot_setting: str """ _attribute_map = { @@ -3327,12 +4705,24 @@ class LinuxProperties(msrest.serialization.Model): def __init__( self, *, - included_package_classifications: Optional[Union[str, "LinuxUpdateClasses"]] = None, + included_package_classifications: Optional[Union[str, "_models.LinuxUpdateClasses"]] = None, excluded_package_name_masks: Optional[List[str]] = None, included_package_name_masks: Optional[List[str]] = None, reboot_setting: Optional[str] = None, **kwargs ): + """ + :keyword included_package_classifications: Update classifications included in the software + update configuration. Known values are: "Unclassified", "Critical", "Security", "Other". + :paramtype included_package_classifications: str or + ~azure.mgmt.automation.models.LinuxUpdateClasses + :keyword excluded_package_name_masks: packages excluded from the software update configuration. + :paramtype excluded_package_name_masks: list[str] + :keyword included_package_name_masks: packages included from the software update configuration. + :paramtype included_package_name_masks: list[str] + :keyword reboot_setting: Reboot setting for the software update configuration. + :paramtype reboot_setting: str + """ super(LinuxProperties, self).__init__(**kwargs) self.included_package_classifications = included_package_classifications self.excluded_package_name_masks = excluded_package_name_masks @@ -3351,38 +4741,38 @@ class Module(TrackedResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param is_global: Gets or sets the isGlobal flag of the module. - :type is_global: bool - :param version: Gets or sets the version of the module. - :type version: str - :param size_in_bytes: Gets or sets the size in bytes of the module. - :type size_in_bytes: long - :param activity_count: Gets or sets the activity count of the module. - :type activity_count: int - :param provisioning_state: Gets or sets the provisioning state of the module. Possible values - include: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar is_global: Gets or sets the isGlobal flag of the module. + :vartype is_global: bool + :ivar version: Gets or sets the version of the module. + :vartype version: str + :ivar size_in_bytes: Gets or sets the size in bytes of the module. + :vartype size_in_bytes: long + :ivar activity_count: Gets or sets the activity count of the module. + :vartype activity_count: int + :ivar provisioning_state: Gets or sets the provisioning state of the module. Known values are: + "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", "Succeeded", "Failed", "Cancelled", "Updating". - :type provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState - :param content_link: Gets or sets the contentLink of the module. - :type content_link: ~azure.mgmt.automation.models.ContentLink - :param error: Gets or sets the error info of the module. - :type error: ~azure.mgmt.automation.models.ModuleErrorInfo - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - :param is_composite: Gets or sets type of module, if its composite or not. - :type is_composite: bool + :vartype provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState + :ivar content_link: Gets or sets the contentLink of the module. + :vartype content_link: ~azure.mgmt.automation.models.ContentLink + :ivar error: Gets or sets the error info of the module. + :vartype error: ~azure.mgmt.automation.models.ModuleErrorInfo + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str + :ivar is_composite: Gets or sets type of module, if its composite or not. + :vartype is_composite: bool """ _validation = { @@ -3421,15 +4811,49 @@ def __init__( version: Optional[str] = None, size_in_bytes: Optional[int] = None, activity_count: Optional[int] = None, - provisioning_state: Optional[Union[str, "ModuleProvisioningState"]] = None, - content_link: Optional["ContentLink"] = None, - error: Optional["ModuleErrorInfo"] = None, + provisioning_state: Optional[Union[str, "_models.ModuleProvisioningState"]] = None, + content_link: Optional["_models.ContentLink"] = None, + error: Optional["_models.ModuleErrorInfo"] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, is_composite: Optional[bool] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword is_global: Gets or sets the isGlobal flag of the module. + :paramtype is_global: bool + :keyword version: Gets or sets the version of the module. + :paramtype version: str + :keyword size_in_bytes: Gets or sets the size in bytes of the module. + :paramtype size_in_bytes: long + :keyword activity_count: Gets or sets the activity count of the module. + :paramtype activity_count: int + :keyword provisioning_state: Gets or sets the provisioning state of the module. Known values + are: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", + "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", + "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", + "Succeeded", "Failed", "Cancelled", "Updating". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState + :keyword content_link: Gets or sets the contentLink of the module. + :paramtype content_link: ~azure.mgmt.automation.models.ContentLink + :keyword error: Gets or sets the error info of the module. + :paramtype error: ~azure.mgmt.automation.models.ModuleErrorInfo + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + :keyword is_composite: Gets or sets type of module, if its composite or not. + :paramtype is_composite: bool + """ super(Module, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.is_global = is_global @@ -3450,14 +4874,14 @@ class ModuleCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar content_link: Required. Gets or sets the module content link. + :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ _validation = { @@ -3474,12 +4898,22 @@ class ModuleCreateOrUpdateParameters(msrest.serialization.Model): def __init__( self, *, - content_link: "ContentLink", + content_link: "_models.ContentLink", name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword content_link: Required. Gets or sets the module content link. + :paramtype content_link: ~azure.mgmt.automation.models.ContentLink + """ super(ModuleCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -3490,10 +4924,10 @@ def __init__( class ModuleErrorInfo(msrest.serialization.Model): """Definition of the module error info type. - :param code: Gets or sets the error code. - :type code: str - :param message: Gets or sets the error message. - :type message: str + :ivar code: Gets or sets the error code. + :vartype code: str + :ivar message: Gets or sets the error message. + :vartype message: str """ _attribute_map = { @@ -3508,6 +4942,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Gets or sets the error code. + :paramtype code: str + :keyword message: Gets or sets the error message. + :paramtype message: str + """ super(ModuleErrorInfo, self).__init__(**kwargs) self.code = code self.message = message @@ -3516,10 +4956,10 @@ def __init__( class ModuleListResult(msrest.serialization.Model): """The response model for the list module operation. - :param value: Gets or sets a list of modules. - :type value: list[~azure.mgmt.automation.models.Module] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of modules. + :vartype value: list[~azure.mgmt.automation.models.Module] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -3530,10 +4970,16 @@ class ModuleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Module"]] = None, + value: Optional[List["_models.Module"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of modules. + :paramtype value: list[~azure.mgmt.automation.models.Module] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(ModuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -3542,14 +4988,14 @@ def __init__( class ModuleUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update module operation. - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink + :ivar name: Gets or sets name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar content_link: Gets or sets the module content link. + :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ _attribute_map = { @@ -3565,9 +5011,19 @@ def __init__( name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - content_link: Optional["ContentLink"] = None, - **kwargs - ): + content_link: Optional["_models.ContentLink"] = None, + **kwargs + ): + """ + :keyword name: Gets or sets name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword content_link: Gets or sets the module content link. + :paramtype content_link: ~azure.mgmt.automation.models.ContentLink + """ super(ModuleUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -3578,10 +5034,10 @@ def __init__( class NodeCount(msrest.serialization.Model): """Number of nodes based on the Filter. - :param name: Gets the name of a count type. - :type name: str - :param properties: - :type properties: ~azure.mgmt.automation.models.NodeCountProperties + :ivar name: Gets the name of a count type. + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.automation.models.NodeCountProperties """ _attribute_map = { @@ -3593,9 +5049,15 @@ def __init__( self, *, name: Optional[str] = None, - properties: Optional["NodeCountProperties"] = None, + properties: Optional["_models.NodeCountProperties"] = None, **kwargs ): + """ + :keyword name: Gets the name of a count type. + :paramtype name: str + :keyword properties: + :paramtype properties: ~azure.mgmt.automation.models.NodeCountProperties + """ super(NodeCount, self).__init__(**kwargs) self.name = name self.properties = properties @@ -3604,8 +5066,8 @@ def __init__( class NodeCountProperties(msrest.serialization.Model): """NodeCountProperties. - :param count: Gets the count for the name. - :type count: int + :ivar count: Gets the count for the name. + :vartype count: int """ _attribute_map = { @@ -3618,6 +5080,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Gets the count for the name. + :paramtype count: int + """ super(NodeCountProperties, self).__init__(**kwargs) self.count = count @@ -3625,10 +5091,10 @@ def __init__( class NodeCounts(msrest.serialization.Model): """Gets the count of nodes by count type. - :param value: Gets an array of counts. - :type value: list[~azure.mgmt.automation.models.NodeCount] - :param total_count: Gets the total number of records matching countType criteria. - :type total_count: int + :ivar value: Gets an array of counts. + :vartype value: list[~azure.mgmt.automation.models.NodeCount] + :ivar total_count: Gets the total number of records matching countType criteria. + :vartype total_count: int """ _attribute_map = { @@ -3639,10 +5105,16 @@ class NodeCounts(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["NodeCount"]] = None, + value: Optional[List["_models.NodeCount"]] = None, total_count: Optional[int] = None, **kwargs ): + """ + :keyword value: Gets an array of counts. + :paramtype value: list[~azure.mgmt.automation.models.NodeCount] + :keyword total_count: Gets the total number of records matching countType criteria. + :paramtype total_count: int + """ super(NodeCounts, self).__init__(**kwargs) self.value = value self.total_count = total_count @@ -3651,10 +5123,10 @@ def __init__( class NonAzureQueryProperties(msrest.serialization.Model): """Non Azure query for the update configuration. - :param function_alias: Log Analytics Saved Search name. - :type function_alias: str - :param workspace_id: Workspace Id for Log Analytics in which the saved Search is resided. - :type workspace_id: str + :ivar function_alias: Log Analytics Saved Search name. + :vartype function_alias: str + :ivar workspace_id: Workspace Id for Log Analytics in which the saved Search is resided. + :vartype workspace_id: str """ _attribute_map = { @@ -3669,6 +5141,12 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword function_alias: Log Analytics Saved Search name. + :paramtype function_alias: str + :keyword workspace_id: Workspace Id for Log Analytics in which the saved Search is resided. + :paramtype workspace_id: str + """ super(NonAzureQueryProperties, self).__init__(**kwargs) self.function_alias = function_alias self.workspace_id = workspace_id @@ -3677,10 +5155,10 @@ def __init__( class Operation(msrest.serialization.Model): """Automation REST API operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Provider, Resource and Operation values. - :type display: ~azure.mgmt.automation.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Provider, Resource and Operation values. + :vartype display: ~azure.mgmt.automation.models.OperationDisplay """ _attribute_map = { @@ -3692,9 +5170,15 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Provider, Resource and Operation values. + :paramtype display: ~azure.mgmt.automation.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -3703,12 +5187,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Provider, Resource and Operation values. - :param provider: Service provider: Microsoft.Automation. - :type provider: str - :param resource: Resource on which the operation is performed: Runbooks, Jobs etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Automation. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Runbooks, Jobs etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -3725,6 +5209,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Automation. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: Runbooks, Jobs etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -3734,8 +5226,8 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The response model for the list of Automation operations. - :param value: List of Automation operations supported by the Automation resource provider. - :type value: list[~azure.mgmt.automation.models.Operation] + :ivar value: List of Automation operations supported by the Automation resource provider. + :vartype value: list[~azure.mgmt.automation.models.Operation] """ _attribute_map = { @@ -3745,15 +5237,19 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): + """ + :keyword value: List of Automation operations supported by the Automation resource provider. + :paramtype value: list[~azure.mgmt.automation.models.Operation] + """ super(OperationListResult, self).__init__(**kwargs) self.value = value -class ProxyResource(Resource): - """ARM proxy resource. +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -3763,6 +5259,14 @@ class ProxyResource(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.automation.models.PrivateEndpointProperty + :ivar group_ids: Gets the groupIds. + :vartype group_ids: list[str] + :ivar private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.automation.models.PrivateLinkServiceConnectionStateProperty """ _validation = { @@ -3775,13 +5279,195 @@ class ProxyResource(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, + 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, + 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, + group_ids: Optional[List[str]] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, + **kwargs + ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.automation.models.PrivateEndpointProperty + :keyword group_ids: Gets the groupIds. + :paramtype group_ids: list[str] + :keyword private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.automation.models.PrivateLinkServiceConnectionStateProperty + """ + super(PrivateEndpointConnection, self).__init__(**kwargs) + self.private_endpoint = private_endpoint + self.group_ids = group_ids + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateEndpointConnectionListResult(msrest.serialization.Model): + """A list of private endpoint connections. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.automation.models.PrivateEndpointConnection] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, } def __init__( self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.automation.models.PrivateEndpointConnection] + """ + super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateEndpointProperty(msrest.serialization.Model): + """Private endpoint which the connection belongs to. + + :ivar id: Resource id of the private endpoint. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ + super(PrivateEndpointProperty, self).__init__(**kwargs) + self.id = id + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'group_id': {'readonly': True}, + 'required_members': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'group_id': {'key': 'properties.groupId', 'type': 'str'}, + 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PrivateLinkResource, self).__init__(**kwargs) + self.group_id = None + self.required_members = None + + +class PrivateLinkResourceListResult(msrest.serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.automation.models.PrivateLinkResource] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateLinkResource"]] = None, + **kwargs + ): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.automation.models.PrivateLinkResource] + """ + super(PrivateLinkResourceListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): + """Connection State of the Private Endpoint Connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The private link service connection status. + :vartype status: str + :ivar description: The private link service connection description. + :vartype description: str + :ivar actions_required: Any action that is required beyond basic workflow (approve/ reject/ + disconnect). + :vartype actions_required: str + """ + + _validation = { + 'actions_required': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + } + + def __init__( + self, + *, + status: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword status: The private link service connection status. + :paramtype status: str + :keyword description: The private link service connection description. + :paramtype description: str + """ + super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = None class PythonPackageCreateParameters(msrest.serialization.Model): @@ -3789,10 +5475,10 @@ class PythonPackageCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar content_link: Required. Gets or sets the module content link. + :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ _validation = { @@ -3807,10 +5493,16 @@ class PythonPackageCreateParameters(msrest.serialization.Model): def __init__( self, *, - content_link: "ContentLink", + content_link: "_models.ContentLink", tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword content_link: Required. Gets or sets the module content link. + :paramtype content_link: ~azure.mgmt.automation.models.ContentLink + """ super(PythonPackageCreateParameters, self).__init__(**kwargs) self.tags = tags self.content_link = content_link @@ -3819,8 +5511,8 @@ def __init__( class PythonPackageUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update module operation. - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -3833,15 +5525,60 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + """ super(PythonPackageUpdateParameters, self).__init__(**kwargs) self.tags = tags +class RawGraphicalRunbookContent(msrest.serialization.Model): + """Raw Graphical Runbook content. + + :ivar schema_version: Schema version of the serializer. + :vartype schema_version: str + :ivar runbook_definition: Serialized Graphical runbook. + :vartype runbook_definition: str + :ivar runbook_type: Runbook Type. Known values are: "GraphPowerShell", + "GraphPowerShellWorkflow". + :vartype runbook_type: str or ~azure.mgmt.automation.models.GraphRunbookType + """ + + _attribute_map = { + 'schema_version': {'key': 'schemaVersion', 'type': 'str'}, + 'runbook_definition': {'key': 'runbookDefinition', 'type': 'str'}, + 'runbook_type': {'key': 'runbookType', 'type': 'str'}, + } + + def __init__( + self, + *, + schema_version: Optional[str] = None, + runbook_definition: Optional[str] = None, + runbook_type: Optional[Union[str, "_models.GraphRunbookType"]] = None, + **kwargs + ): + """ + :keyword schema_version: Schema version of the serializer. + :paramtype schema_version: str + :keyword runbook_definition: Serialized Graphical runbook. + :paramtype runbook_definition: str + :keyword runbook_type: Runbook Type. Known values are: "GraphPowerShell", + "GraphPowerShellWorkflow". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.GraphRunbookType + """ + super(RawGraphicalRunbookContent, self).__init__(**kwargs) + self.schema_version = schema_version + self.runbook_definition = runbook_definition + self.runbook_type = runbook_type + + class RunAsCredentialAssociationProperty(msrest.serialization.Model): """Definition of RunAs credential to use for hybrid worker. - :param name: Gets or sets the name of the credential. - :type name: str + :ivar name: Gets or sets the name of the credential. + :vartype name: str """ _attribute_map = { @@ -3854,6 +5591,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the credential. + :paramtype name: str + """ super(RunAsCredentialAssociationProperty, self).__init__(**kwargs) self.name = name @@ -3869,52 +5610,52 @@ class Runbook(TrackedResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param runbook_type: Gets or sets the type of the runbook. Possible values include: "Script", - "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param state: Gets or sets the state of the runbook. Possible values include: "New", "Edit", + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar runbook_type: Gets or sets the type of the runbook. Known values are: "Script", "Graph", + "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", "Python2", + "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar publish_content_link: Gets or sets the published runbook content link. + :vartype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar state: Gets or sets the state of the runbook. Known values are: "New", "Edit", "Published". - :type state: str or ~azure.mgmt.automation.models.RunbookState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the option to log activity trace of the runbook. - :type log_activity_trace: int - :param job_count: Gets or sets the job count of the runbook. - :type job_count: int - :param parameters: Gets or sets the runbook parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :ivar provisioning_state: Gets or sets the provisioning state of the runbook. Default value: - "Succeeded". + :vartype state: str or ~azure.mgmt.automation.models.RunbookState + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar log_activity_trace: Gets or sets the option to log activity trace of the runbook. + :vartype log_activity_trace: int + :ivar job_count: Gets or sets the job count of the runbook. + :vartype job_count: int + :ivar parameters: Gets or sets the runbook parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] + :ivar output_types: Gets or sets the runbook output types. + :vartype output_types: list[str] + :ivar draft: Gets or sets the draft runbook properties. + :vartype draft: ~azure.mgmt.automation.models.RunbookDraft + :ivar provisioning_state: Gets or sets the provisioning state of the runbook. The only + acceptable values to pass in are None and "Succeeded". The default value is None. :vartype provisioning_state: str - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar last_modified_by: Gets or sets the last modified by. + :vartype last_modified_by: str + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, } _attribute_map = { @@ -3941,30 +5682,71 @@ class Runbook(TrackedResource): 'description': {'key': 'properties.description', 'type': 'str'}, } - provisioning_state = "Succeeded" - def __init__( self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, etag: Optional[str] = None, - runbook_type: Optional[Union[str, "RunbookTypeEnum"]] = None, - publish_content_link: Optional["ContentLink"] = None, - state: Optional[Union[str, "RunbookState"]] = None, + runbook_type: Optional[Union[str, "_models.RunbookTypeEnum"]] = None, + publish_content_link: Optional["_models.ContentLink"] = None, + state: Optional[Union[str, "_models.RunbookState"]] = None, log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, log_activity_trace: Optional[int] = None, job_count: Optional[int] = None, - parameters: Optional[Dict[str, "RunbookParameter"]] = None, + parameters: Optional[Dict[str, "_models.RunbookParameter"]] = None, output_types: Optional[List[str]] = None, - draft: Optional["RunbookDraft"] = None, + draft: Optional["_models.RunbookDraft"] = None, + provisioning_state: Optional[str] = None, last_modified_by: Optional[str] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The Azure Region where the resource lives. + :paramtype location: str + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword runbook_type: Gets or sets the type of the runbook. Known values are: "Script", + "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", + "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword publish_content_link: Gets or sets the published runbook content link. + :paramtype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :keyword state: Gets or sets the state of the runbook. Known values are: "New", "Edit", + "Published". + :paramtype state: str or ~azure.mgmt.automation.models.RunbookState + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword log_activity_trace: Gets or sets the option to log activity trace of the runbook. + :paramtype log_activity_trace: int + :keyword job_count: Gets or sets the job count of the runbook. + :paramtype job_count: int + :keyword parameters: Gets or sets the runbook parameters. + :paramtype parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] + :keyword output_types: Gets or sets the runbook output types. + :paramtype output_types: list[str] + :keyword draft: Gets or sets the draft runbook properties. + :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft + :keyword provisioning_state: Gets or sets the provisioning state of the runbook. The only + acceptable values to pass in are None and "Succeeded". The default value is None. + :paramtype provisioning_state: str + :keyword last_modified_by: Gets or sets the last modified by. + :paramtype last_modified_by: str + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Runbook, self).__init__(tags=tags, location=location, **kwargs) self.etag = etag self.runbook_type = runbook_type @@ -3977,6 +5759,7 @@ def __init__( self.parameters = parameters self.output_types = output_types self.draft = draft + self.provisioning_state = provisioning_state self.last_modified_by = last_modified_by self.creation_time = creation_time self.last_modified_time = last_modified_time @@ -3986,8 +5769,8 @@ def __init__( class RunbookAssociationProperty(msrest.serialization.Model): """The runbook property associated with the entity. - :param name: Gets or sets the name of the runbook. - :type name: str + :ivar name: Gets or sets the name of the runbook. + :vartype name: str """ _attribute_map = { @@ -4000,6 +5783,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the runbook. + :paramtype name: str + """ super(RunbookAssociationProperty, self).__init__(**kwargs) self.name = name @@ -4009,8 +5796,8 @@ class RunbookCreateOrUpdateDraftParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param runbook_content: Required. Content of the Runbook. - :type runbook_content: str + :ivar runbook_content: Required. Content of the Runbook. + :vartype runbook_content: str """ _validation = { @@ -4027,6 +5814,10 @@ def __init__( runbook_content: str, **kwargs ): + """ + :keyword runbook_content: Required. Content of the Runbook. + :paramtype runbook_content: str + """ super(RunbookCreateOrUpdateDraftParameters, self).__init__(**kwargs) self.runbook_content = runbook_content @@ -4036,20 +5827,20 @@ class RunbookCreateOrUpdateDraftProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Required. Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar runbook_type: Required. Gets or sets the type of the runbook. Known values are: "Script", + "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", + "Python2", "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar draft: Required. Gets or sets the draft runbook properties. + :vartype draft: ~azure.mgmt.automation.models.RunbookDraft + :ivar description: Gets or sets the description of the runbook. + :vartype description: str + :ivar log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _validation = { @@ -4069,14 +5860,30 @@ class RunbookCreateOrUpdateDraftProperties(msrest.serialization.Model): def __init__( self, *, - runbook_type: Union[str, "RunbookTypeEnum"], - draft: "RunbookDraft", + runbook_type: Union[str, "_models.RunbookTypeEnum"], + draft: "_models.RunbookDraft", log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, description: Optional[str] = None, log_activity_trace: Optional[int] = None, **kwargs ): + """ + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword runbook_type: Required. Gets or sets the type of the runbook. Known values are: + "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", + "GraphPowerShell", "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword draft: Required. Gets or sets the draft runbook properties. + :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft + :keyword description: Gets or sets the description of the runbook. + :paramtype description: str + :keyword log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(RunbookCreateOrUpdateDraftProperties, self).__init__(**kwargs) self.log_verbose = log_verbose self.log_progress = log_progress @@ -4091,28 +5898,28 @@ class RunbookCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar runbook_type: Required. Gets or sets the type of the runbook. Known values are: "Script", + "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", + "Python2", "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar draft: Gets or sets the draft runbook properties. + :vartype draft: ~azure.mgmt.automation.models.RunbookDraft + :ivar publish_content_link: Gets or sets the published runbook content link. + :vartype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar description: Gets or sets the description of the runbook. + :vartype description: str + :ivar log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _validation = { @@ -4135,18 +5942,42 @@ class RunbookCreateOrUpdateParameters(msrest.serialization.Model): def __init__( self, *, - runbook_type: Union[str, "RunbookTypeEnum"], + runbook_type: Union[str, "_models.RunbookTypeEnum"], name: Optional[str] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, log_verbose: Optional[bool] = None, log_progress: Optional[bool] = None, - draft: Optional["RunbookDraft"] = None, - publish_content_link: Optional["ContentLink"] = None, + draft: Optional["_models.RunbookDraft"] = None, + publish_content_link: Optional["_models.ContentLink"] = None, description: Optional[str] = None, log_activity_trace: Optional[int] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword runbook_type: Required. Gets or sets the type of the runbook. Known values are: + "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", + "GraphPowerShell", "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword draft: Gets or sets the draft runbook properties. + :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft + :keyword publish_content_link: Gets or sets the published runbook content link. + :paramtype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :keyword description: Gets or sets the description of the runbook. + :paramtype description: str + :keyword log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(RunbookCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -4163,18 +5994,18 @@ def __init__( class RunbookDraft(msrest.serialization.Model): """RunbookDraft. - :param in_edit: Gets or sets whether runbook is in edit mode. - :type in_edit: bool - :param draft_content_link: Gets or sets the draft runbook content link. - :type draft_content_link: ~azure.mgmt.automation.models.ContentLink - :param creation_time: Gets or sets the creation time of the runbook draft. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time of the runbook draft. - :type last_modified_time: ~datetime.datetime - :param parameters: Gets or sets the runbook draft parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] + :ivar in_edit: Gets or sets whether runbook is in edit mode. + :vartype in_edit: bool + :ivar draft_content_link: Gets or sets the draft runbook content link. + :vartype draft_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar creation_time: Gets or sets the creation time of the runbook draft. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time of the runbook draft. + :vartype last_modified_time: ~datetime.datetime + :ivar parameters: Gets or sets the runbook draft parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] + :ivar output_types: Gets or sets the runbook output types. + :vartype output_types: list[str] """ _attribute_map = { @@ -4190,13 +6021,27 @@ def __init__( self, *, in_edit: Optional[bool] = None, - draft_content_link: Optional["ContentLink"] = None, + draft_content_link: Optional["_models.ContentLink"] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, - parameters: Optional[Dict[str, "RunbookParameter"]] = None, + parameters: Optional[Dict[str, "_models.RunbookParameter"]] = None, output_types: Optional[List[str]] = None, **kwargs ): + """ + :keyword in_edit: Gets or sets whether runbook is in edit mode. + :paramtype in_edit: bool + :keyword draft_content_link: Gets or sets the draft runbook content link. + :paramtype draft_content_link: ~azure.mgmt.automation.models.ContentLink + :keyword creation_time: Gets or sets the creation time of the runbook draft. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time of the runbook draft. + :paramtype last_modified_time: ~datetime.datetime + :keyword parameters: Gets or sets the runbook draft parameters. + :paramtype parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] + :keyword output_types: Gets or sets the runbook output types. + :paramtype output_types: list[str] + """ super(RunbookDraft, self).__init__(**kwargs) self.in_edit = in_edit self.draft_content_link = draft_content_link @@ -4209,20 +6054,19 @@ def __init__( class RunbookDraftUndoEditResult(msrest.serialization.Model): """The response model for the undo edit runbook operation. - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + :ivar status_code: Known values are: "Continue", "SwitchingProtocols", "OK", "Created", + "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", + "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", "Redirect", "SeeOther", + "RedirectMethod", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "RedirectKeepVerb", + "BadRequest", "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", + "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", + "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", + "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", + "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.automation.models.HttpStatusCode - :param request_id: - :type request_id: str + :vartype status_code: str or ~azure.mgmt.automation.models.HttpStatusCode + :ivar request_id: + :vartype request_id: str """ _attribute_map = { @@ -4233,10 +6077,25 @@ class RunbookDraftUndoEditResult(msrest.serialization.Model): def __init__( self, *, - status_code: Optional[Union[str, "HttpStatusCode"]] = None, + status_code: Optional[Union[str, "_models.HttpStatusCode"]] = None, request_id: Optional[str] = None, **kwargs ): + """ + :keyword status_code: Known values are: "Continue", "SwitchingProtocols", "OK", "Created", + "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", + "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", "Redirect", "SeeOther", + "RedirectMethod", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "RedirectKeepVerb", + "BadRequest", "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", + "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", + "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", + "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", + "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + "HttpVersionNotSupported". + :paramtype status_code: str or ~azure.mgmt.automation.models.HttpStatusCode + :keyword request_id: + :paramtype request_id: str + """ super(RunbookDraftUndoEditResult, self).__init__(**kwargs) self.status_code = status_code self.request_id = request_id @@ -4245,10 +6104,10 @@ def __init__( class RunbookListResult(msrest.serialization.Model): """The response model for the list runbook operation. - :param value: Gets or sets a list of runbooks. - :type value: list[~azure.mgmt.automation.models.Runbook] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of runbooks. + :vartype value: list[~azure.mgmt.automation.models.Runbook] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -4259,10 +6118,16 @@ class RunbookListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Runbook"]] = None, + value: Optional[List["_models.Runbook"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of runbooks. + :paramtype value: list[~azure.mgmt.automation.models.Runbook] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(RunbookListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -4271,15 +6136,15 @@ def __init__( class RunbookParameter(msrest.serialization.Model): """Definition of the runbook parameter type. - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str + :ivar type: Gets or sets the type of the parameter. + :vartype type: str + :ivar is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is mandatory + or not. + :vartype is_mandatory: bool + :ivar position: Get or sets the position of the parameter. + :vartype position: int + :ivar default_value: Gets or sets the default value of parameter. + :vartype default_value: str """ _attribute_map = { @@ -4298,6 +6163,17 @@ def __init__( default_value: Optional[str] = None, **kwargs ): + """ + :keyword type: Gets or sets the type of the parameter. + :paramtype type: str + :keyword is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is + mandatory or not. + :paramtype is_mandatory: bool + :keyword position: Get or sets the position of the parameter. + :paramtype position: int + :keyword default_value: Gets or sets the default value of parameter. + :paramtype default_value: str + """ super(RunbookParameter, self).__init__(**kwargs) self.type = type self.is_mandatory = is_mandatory @@ -4308,20 +6184,20 @@ def __init__( class RunbookUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update runbook operation. - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar location: Gets or sets the location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar description: Gets or sets the description of the runbook. + :vartype description: str + :ivar log_verbose: Gets or sets verbose log option. + :vartype log_verbose: bool + :ivar log_progress: Gets or sets progress log option. + :vartype log_progress: bool + :ivar log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _attribute_map = { @@ -4346,6 +6222,22 @@ def __init__( log_activity_trace: Optional[int] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the resource. + :paramtype name: str + :keyword location: Gets or sets the location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + :keyword description: Gets or sets the description of the runbook. + :paramtype description: str + :keyword log_verbose: Gets or sets verbose log option. + :paramtype log_verbose: bool + :keyword log_progress: Gets or sets progress log option. + :paramtype log_progress: bool + :keyword log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(RunbookUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -4356,7 +6248,7 @@ def __init__( self.log_activity_trace = log_activity_trace -class Schedule(Resource): +class Schedule(ProxyResource): """Definition of the schedule. Variables are only populated by the server, and will be ignored when sending a request. @@ -4367,35 +6259,35 @@ class Schedule(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime + :ivar start_time: Gets or sets the start time of the schedule. + :vartype start_time: ~datetime.datetime :ivar start_time_offset_minutes: Gets the start time's offset in minutes. :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar expiry_time: Gets or sets the end time of the schedule. + :vartype expiry_time: ~datetime.datetime + :ivar expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. + :vartype expiry_time_offset_minutes: float + :ivar is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :vartype is_enabled: bool + :ivar next_run: Gets or sets the next run time of the schedule. + :vartype next_run: ~datetime.datetime + :ivar next_run_offset_minutes: Gets or sets the next run time's offset in minutes. + :vartype next_run_offset_minutes: float + :ivar interval: Gets or sets the interval of the schedule. + :vartype interval: any + :ivar frequency: Gets or sets the frequency of the schedule. Known values are: "OneTime", + "Day", "Hour", "Week", "Month", "Minute". + :vartype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :ivar time_zone: Gets or sets the time zone of the schedule. + :vartype time_zone: str + :ivar advanced_schedule: Gets or sets the advanced schedule. + :vartype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -4434,15 +6326,44 @@ def __init__( is_enabled: Optional[bool] = False, next_run: Optional[datetime.datetime] = None, next_run_offset_minutes: Optional[float] = None, - interval: Optional[object] = None, - frequency: Optional[Union[str, "ScheduleFrequency"]] = None, + interval: Optional[Any] = None, + frequency: Optional[Union[str, "_models.ScheduleFrequency"]] = None, time_zone: Optional[str] = None, - advanced_schedule: Optional["AdvancedSchedule"] = None, + advanced_schedule: Optional["_models.AdvancedSchedule"] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword start_time: Gets or sets the start time of the schedule. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Gets or sets the end time of the schedule. + :paramtype expiry_time: ~datetime.datetime + :keyword expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. + :paramtype expiry_time_offset_minutes: float + :keyword is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :paramtype is_enabled: bool + :keyword next_run: Gets or sets the next run time of the schedule. + :paramtype next_run: ~datetime.datetime + :keyword next_run_offset_minutes: Gets or sets the next run time's offset in minutes. + :paramtype next_run_offset_minutes: float + :keyword interval: Gets or sets the interval of the schedule. + :paramtype interval: any + :keyword frequency: Gets or sets the frequency of the schedule. Known values are: "OneTime", + "Day", "Hour", "Week", "Month", "Minute". + :paramtype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :keyword time_zone: Gets or sets the time zone of the schedule. + :paramtype time_zone: str + :keyword advanced_schedule: Gets or sets the advanced schedule. + :paramtype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Schedule, self).__init__(**kwargs) self.start_time = start_time self.start_time_offset_minutes = None @@ -4463,8 +6384,8 @@ def __init__( class ScheduleAssociationProperty(msrest.serialization.Model): """The schedule property associated with the entity. - :param name: Gets or sets the name of the Schedule. - :type name: str + :ivar name: Gets or sets the name of the Schedule. + :vartype name: str """ _attribute_map = { @@ -4477,6 +6398,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the Schedule. + :paramtype name: str + """ super(ScheduleAssociationProperty, self).__init__(**kwargs) self.name = name @@ -4486,23 +6411,23 @@ class ScheduleCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param start_time: Required. Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Required. Gets or sets the frequency of the schedule. Possible values - include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the AdvancedSchedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + :ivar name: Required. Gets or sets the name of the Schedule. + :vartype name: str + :ivar description: Gets or sets the description of the schedule. + :vartype description: str + :ivar start_time: Required. Gets or sets the start time of the schedule. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Gets or sets the end time of the schedule. + :vartype expiry_time: ~datetime.datetime + :ivar interval: Gets or sets the interval of the schedule. + :vartype interval: any + :ivar frequency: Required. Gets or sets the frequency of the schedule. Known values are: + "OneTime", "Day", "Hour", "Week", "Month", "Minute". + :vartype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :ivar time_zone: Gets or sets the time zone of the schedule. + :vartype time_zone: str + :ivar advanced_schedule: Gets or sets the AdvancedSchedule. + :vartype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule """ _validation = { @@ -4527,14 +6452,33 @@ def __init__( *, name: str, start_time: datetime.datetime, - frequency: Union[str, "ScheduleFrequency"], + frequency: Union[str, "_models.ScheduleFrequency"], description: Optional[str] = None, expiry_time: Optional[datetime.datetime] = None, - interval: Optional[object] = None, + interval: Optional[Any] = None, time_zone: Optional[str] = None, - advanced_schedule: Optional["AdvancedSchedule"] = None, - **kwargs - ): + advanced_schedule: Optional["_models.AdvancedSchedule"] = None, + **kwargs + ): + """ + :keyword name: Required. Gets or sets the name of the Schedule. + :paramtype name: str + :keyword description: Gets or sets the description of the schedule. + :paramtype description: str + :keyword start_time: Required. Gets or sets the start time of the schedule. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Gets or sets the end time of the schedule. + :paramtype expiry_time: ~datetime.datetime + :keyword interval: Gets or sets the interval of the schedule. + :paramtype interval: any + :keyword frequency: Required. Gets or sets the frequency of the schedule. Known values are: + "OneTime", "Day", "Hour", "Week", "Month", "Minute". + :paramtype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :keyword time_zone: Gets or sets the time zone of the schedule. + :paramtype time_zone: str + :keyword advanced_schedule: Gets or sets the AdvancedSchedule. + :paramtype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + """ super(ScheduleCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.description = description @@ -4549,10 +6493,10 @@ def __init__( class ScheduleListResult(msrest.serialization.Model): """The response model for the list schedule operation. - :param value: Gets or sets a list of schedules. - :type value: list[~azure.mgmt.automation.models.Schedule] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of schedules. + :vartype value: list[~azure.mgmt.automation.models.Schedule] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -4563,10 +6507,16 @@ class ScheduleListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Schedule"]] = None, + value: Optional[List["_models.Schedule"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of schedules. + :paramtype value: list[~azure.mgmt.automation.models.Schedule] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(ScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -4575,12 +6525,12 @@ def __init__( class ScheduleUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update schedule operation. - :param name: Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool + :ivar name: Gets or sets the name of the Schedule. + :vartype name: str + :ivar description: Gets or sets the description of the schedule. + :vartype description: str + :ivar is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :vartype is_enabled: bool """ _attribute_map = { @@ -4597,6 +6547,14 @@ def __init__( is_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the Schedule. + :paramtype name: str + :keyword description: Gets or sets the description of the schedule. + :paramtype description: str + :keyword is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :paramtype is_enabled: bool + """ super(ScheduleUpdateParameters, self).__init__(**kwargs) self.name = name self.description = description @@ -4608,13 +6566,13 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the SKU name of the account. Possible values include: - "Free", "Basic". - :type name: str or ~azure.mgmt.automation.models.SkuNameEnum - :param family: Gets or sets the SKU family. - :type family: str - :param capacity: Gets or sets the SKU capacity. - :type capacity: int + :ivar name: Required. Gets or sets the SKU name of the account. Known values are: "Free", + "Basic". + :vartype name: str or ~azure.mgmt.automation.models.SkuNameEnum + :ivar family: Gets or sets the SKU family. + :vartype family: str + :ivar capacity: Gets or sets the SKU capacity. + :vartype capacity: int """ _validation = { @@ -4630,11 +6588,20 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuNameEnum"], + name: Union[str, "_models.SkuNameEnum"], family: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the SKU name of the account. Known values are: "Free", + "Basic". + :paramtype name: str or ~azure.mgmt.automation.models.SkuNameEnum + :keyword family: Gets or sets the SKU family. + :paramtype family: str + :keyword capacity: Gets or sets the SKU capacity. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.family = family @@ -4654,16 +6621,16 @@ class SoftwareUpdateConfiguration(msrest.serialization.Model): :vartype id: str :ivar type: Resource type. :vartype type: str - :param update_configuration: Required. update specific properties for the Software update + :ivar update_configuration: Required. update specific properties for the Software update configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param schedule_info: Required. Schedule information for the Software update configuration. - :type schedule_info: ~azure.mgmt.automation.models.SUCScheduleProperties + :vartype update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration + :ivar schedule_info: Required. Schedule information for the Software update configuration. + :vartype schedule_info: ~azure.mgmt.automation.models.SUCScheduleProperties :ivar provisioning_state: Provisioning state for the software update configuration, which only appears in the response. :vartype provisioning_state: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse + :ivar error: Details of provisioning error. + :vartype error: ~azure.mgmt.automation.models.ErrorResponse :ivar creation_time: Creation time of the resource, which only appears in the response. :vartype creation_time: ~datetime.datetime :ivar created_by: CreatedBy property, which only appears in the response. @@ -4672,8 +6639,8 @@ class SoftwareUpdateConfiguration(msrest.serialization.Model): :vartype last_modified_time: ~datetime.datetime :ivar last_modified_by: LastModifiedBy property, which only appears in the response. :vartype last_modified_by: str - :param tasks: Tasks information for the Software update configuration. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks + :ivar tasks: Tasks information for the Software update configuration. + :vartype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks """ _validation = { @@ -4707,12 +6674,23 @@ class SoftwareUpdateConfiguration(msrest.serialization.Model): def __init__( self, *, - update_configuration: "UpdateConfiguration", - schedule_info: "SUCScheduleProperties", - error: Optional["ErrorResponse"] = None, - tasks: Optional["SoftwareUpdateConfigurationTasks"] = None, + update_configuration: "_models.UpdateConfiguration", + schedule_info: "_models.SUCScheduleProperties", + error: Optional["_models.ErrorResponse"] = None, + tasks: Optional["_models.SoftwareUpdateConfigurationTasks"] = None, **kwargs ): + """ + :keyword update_configuration: Required. update specific properties for the Software update + configuration. + :paramtype update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration + :keyword schedule_info: Required. Schedule information for the Software update configuration. + :paramtype schedule_info: ~azure.mgmt.automation.models.SUCScheduleProperties + :keyword error: Details of provisioning error. + :paramtype error: ~azure.mgmt.automation.models.ErrorResponse + :keyword tasks: Tasks information for the Software update configuration. + :paramtype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks + """ super(SoftwareUpdateConfiguration, self).__init__(**kwargs) self.name = None self.id = None @@ -4737,15 +6715,15 @@ class SoftwareUpdateConfigurationCollectionItem(msrest.serialization.Model): :vartype name: str :ivar id: Resource Id of the software update configuration. :vartype id: str - :param update_configuration: Update specific properties of the software update configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param tasks: Pre and Post Tasks defined. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks - :param frequency: execution frequency of the schedule associated with the software update - configuration. Possible values include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param start_time: the start time of the update. - :type start_time: ~datetime.datetime + :ivar update_configuration: Update specific properties of the software update configuration. + :vartype update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration + :ivar tasks: Pre and Post Tasks defined. + :vartype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks + :ivar frequency: execution frequency of the schedule associated with the software update + configuration. Known values are: "OneTime", "Day", "Hour", "Week", "Month", "Minute". + :vartype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :ivar start_time: the start time of the update. + :vartype start_time: ~datetime.datetime :ivar creation_time: Creation time of the software update configuration, which only appears in the response. :vartype creation_time: ~datetime.datetime @@ -4755,8 +6733,8 @@ class SoftwareUpdateConfigurationCollectionItem(msrest.serialization.Model): :ivar provisioning_state: Provisioning state for the software update configuration, which only appears in the response. :vartype provisioning_state: str - :param next_run: ext run time of the update. - :type next_run: ~datetime.datetime + :ivar next_run: ext run time of the update. + :vartype next_run: ~datetime.datetime """ _validation = { @@ -4783,13 +6761,26 @@ class SoftwareUpdateConfigurationCollectionItem(msrest.serialization.Model): def __init__( self, *, - update_configuration: Optional["UpdateConfiguration"] = None, - tasks: Optional["SoftwareUpdateConfigurationTasks"] = None, - frequency: Optional[Union[str, "ScheduleFrequency"]] = None, + update_configuration: Optional["_models.UpdateConfiguration"] = None, + tasks: Optional["_models.SoftwareUpdateConfigurationTasks"] = None, + frequency: Optional[Union[str, "_models.ScheduleFrequency"]] = None, start_time: Optional[datetime.datetime] = None, next_run: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword update_configuration: Update specific properties of the software update configuration. + :paramtype update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration + :keyword tasks: Pre and Post Tasks defined. + :paramtype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks + :keyword frequency: execution frequency of the schedule associated with the software update + configuration. Known values are: "OneTime", "Day", "Hour", "Week", "Month", "Minute". + :paramtype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :keyword start_time: the start time of the update. + :paramtype start_time: ~datetime.datetime + :keyword next_run: ext run time of the update. + :paramtype next_run: ~datetime.datetime + """ super(SoftwareUpdateConfigurationCollectionItem, self).__init__(**kwargs) self.name = None self.id = None @@ -4806,8 +6797,8 @@ def __init__( class SoftwareUpdateConfigurationListResult(msrest.serialization.Model): """result of listing all software update configuration. - :param value: outer object returned when listing all software update configurations. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] + :ivar value: outer object returned when listing all software update configurations. + :vartype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] """ _attribute_map = { @@ -4817,9 +6808,13 @@ class SoftwareUpdateConfigurationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SoftwareUpdateConfigurationCollectionItem"]] = None, + value: Optional[List["_models.SoftwareUpdateConfigurationCollectionItem"]] = None, **kwargs ): + """ + :keyword value: outer object returned when listing all software update configurations. + :paramtype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] + """ super(SoftwareUpdateConfigurationListResult, self).__init__(**kwargs) self.value = value @@ -4837,8 +6832,8 @@ class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): :vartype target_computer: str :ivar target_computer_type: type of the updated computer. :vartype target_computer_type: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: + :ivar software_update_configuration: software update configuration triggered this run. + :vartype software_update_configuration: ~azure.mgmt.automation.models.UpdateConfigurationNavigation :ivar status: Status of the software update configuration machine run. :vartype status: str @@ -4854,8 +6849,8 @@ class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar configured_duration: configured duration for the software update configuration run. :vartype configured_duration: str - :param job: Job associated with the software update configuration machine run. - :type job: ~azure.mgmt.automation.models.JobNavigation + :ivar job: Job associated with the software update configuration machine run. + :vartype job: ~azure.mgmt.automation.models.JobNavigation :ivar creation_time: Creation time of the resource, which only appears in the response. :vartype creation_time: ~datetime.datetime :ivar created_by: createdBy property, which only appears in the response. @@ -4864,8 +6859,8 @@ class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): :vartype last_modified_time: ~datetime.datetime :ivar last_modified_by: lastModifiedBy property, which only appears in the response. :vartype last_modified_by: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse + :ivar error: Details of provisioning error. + :vartype error: ~azure.mgmt.automation.models.ErrorResponse """ _validation = { @@ -4910,11 +6905,20 @@ class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): def __init__( self, *, - software_update_configuration: Optional["UpdateConfigurationNavigation"] = None, - job: Optional["JobNavigation"] = None, - error: Optional["ErrorResponse"] = None, + software_update_configuration: Optional["_models.UpdateConfigurationNavigation"] = None, + job: Optional["_models.JobNavigation"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): + """ + :keyword software_update_configuration: software update configuration triggered this run. + :paramtype software_update_configuration: + ~azure.mgmt.automation.models.UpdateConfigurationNavigation + :keyword job: Job associated with the software update configuration machine run. + :paramtype job: ~azure.mgmt.automation.models.JobNavigation + :keyword error: Details of provisioning error. + :paramtype error: ~azure.mgmt.automation.models.ErrorResponse + """ super(SoftwareUpdateConfigurationMachineRun, self).__init__(**kwargs) self.name = None self.id = None @@ -4939,11 +6943,10 @@ def __init__( class SoftwareUpdateConfigurationMachineRunListResult(msrest.serialization.Model): """result of listing all software update configuration machine runs. - :param value: outer object returned when listing all software update configuration machine - runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun] - :param next_link: link to next page of results. - :type next_link: str + :ivar value: outer object returned when listing all software update configuration machine runs. + :vartype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun] + :ivar next_link: link to next page of results. + :vartype next_link: str """ _attribute_map = { @@ -4954,10 +6957,17 @@ class SoftwareUpdateConfigurationMachineRunListResult(msrest.serialization.Model def __init__( self, *, - value: Optional[List["SoftwareUpdateConfigurationMachineRun"]] = None, + value: Optional[List["_models.SoftwareUpdateConfigurationMachineRun"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: outer object returned when listing all software update configuration machine + runs. + :paramtype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun] + :keyword next_link: link to next page of results. + :paramtype next_link: str + """ super(SoftwareUpdateConfigurationMachineRunListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -4972,8 +6982,8 @@ class SoftwareUpdateConfigurationRun(msrest.serialization.Model): :vartype name: str :ivar id: Resource Id of the software update configuration run. :vartype id: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: + :ivar software_update_configuration: software update configuration triggered this run. + :vartype software_update_configuration: ~azure.mgmt.automation.models.UpdateConfigurationNavigation :ivar status: Status of the software update configuration run. :vartype status: str @@ -4997,8 +7007,8 @@ class SoftwareUpdateConfigurationRun(msrest.serialization.Model): :vartype last_modified_time: ~datetime.datetime :ivar last_modified_by: LastModifiedBy property, which only appears in the response. :vartype last_modified_by: str - :param tasks: Software update configuration tasks triggered in this run. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTasks + :ivar tasks: Software update configuration tasks triggered in this run. + :vartype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTasks """ _validation = { @@ -5038,10 +7048,17 @@ class SoftwareUpdateConfigurationRun(msrest.serialization.Model): def __init__( self, *, - software_update_configuration: Optional["UpdateConfigurationNavigation"] = None, - tasks: Optional["SoftwareUpdateConfigurationRunTasks"] = None, + software_update_configuration: Optional["_models.UpdateConfigurationNavigation"] = None, + tasks: Optional["_models.SoftwareUpdateConfigurationRunTasks"] = None, **kwargs ): + """ + :keyword software_update_configuration: software update configuration triggered this run. + :paramtype software_update_configuration: + ~azure.mgmt.automation.models.UpdateConfigurationNavigation + :keyword tasks: Software update configuration tasks triggered in this run. + :paramtype tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTasks + """ super(SoftwareUpdateConfigurationRun, self).__init__(**kwargs) self.name = None self.id = None @@ -5063,10 +7080,10 @@ def __init__( class SoftwareUpdateConfigurationRunListResult(msrest.serialization.Model): """result of listing all software update configuration runs. - :param value: outer object returned when listing all software update configuration runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] - :param next_link: link to next page of results. - :type next_link: str + :ivar value: outer object returned when listing all software update configuration runs. + :vartype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] + :ivar next_link: link to next page of results. + :vartype next_link: str """ _attribute_map = { @@ -5077,10 +7094,16 @@ class SoftwareUpdateConfigurationRunListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SoftwareUpdateConfigurationRun"]] = None, + value: Optional[List["_models.SoftwareUpdateConfigurationRun"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: outer object returned when listing all software update configuration runs. + :paramtype value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] + :keyword next_link: link to next page of results. + :paramtype next_link: str + """ super(SoftwareUpdateConfigurationRunListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5089,12 +7112,12 @@ def __init__( class SoftwareUpdateConfigurationRunTaskProperties(msrest.serialization.Model): """Task properties of the software update configuration. - :param status: The status of the task. - :type status: str - :param source: The name of the source of the task. - :type source: str - :param job_id: The job id of the task. - :type job_id: str + :ivar status: The status of the task. + :vartype status: str + :ivar source: The name of the source of the task. + :vartype source: str + :ivar job_id: The job id of the task. + :vartype job_id: str """ _attribute_map = { @@ -5111,6 +7134,14 @@ def __init__( job_id: Optional[str] = None, **kwargs ): + """ + :keyword status: The status of the task. + :paramtype status: str + :keyword source: The name of the source of the task. + :paramtype source: str + :keyword job_id: The job id of the task. + :paramtype job_id: str + """ super(SoftwareUpdateConfigurationRunTaskProperties, self).__init__(**kwargs) self.status = status self.source = source @@ -5120,10 +7151,10 @@ def __init__( class SoftwareUpdateConfigurationRunTasks(msrest.serialization.Model): """Software update configuration run tasks model. - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties + :ivar pre_task: Pre task properties. + :vartype pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties + :ivar post_task: Post task properties. + :vartype post_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties """ _attribute_map = { @@ -5134,10 +7165,17 @@ class SoftwareUpdateConfigurationRunTasks(msrest.serialization.Model): def __init__( self, *, - pre_task: Optional["SoftwareUpdateConfigurationRunTaskProperties"] = None, - post_task: Optional["SoftwareUpdateConfigurationRunTaskProperties"] = None, + pre_task: Optional["_models.SoftwareUpdateConfigurationRunTaskProperties"] = None, + post_task: Optional["_models.SoftwareUpdateConfigurationRunTaskProperties"] = None, **kwargs ): + """ + :keyword pre_task: Pre task properties. + :paramtype pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties + :keyword post_task: Post task properties. + :paramtype post_task: + ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties + """ super(SoftwareUpdateConfigurationRunTasks, self).__init__(**kwargs) self.pre_task = pre_task self.post_task = post_task @@ -5146,10 +7184,10 @@ def __init__( class SoftwareUpdateConfigurationTasks(msrest.serialization.Model): """Task properties of the software update configuration. - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.TaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.TaskProperties + :ivar pre_task: Pre task properties. + :vartype pre_task: ~azure.mgmt.automation.models.TaskProperties + :ivar post_task: Post task properties. + :vartype post_task: ~azure.mgmt.automation.models.TaskProperties """ _attribute_map = { @@ -5160,16 +7198,22 @@ class SoftwareUpdateConfigurationTasks(msrest.serialization.Model): def __init__( self, *, - pre_task: Optional["TaskProperties"] = None, - post_task: Optional["TaskProperties"] = None, + pre_task: Optional["_models.TaskProperties"] = None, + post_task: Optional["_models.TaskProperties"] = None, **kwargs ): + """ + :keyword pre_task: Pre task properties. + :paramtype pre_task: ~azure.mgmt.automation.models.TaskProperties + :keyword post_task: Post task properties. + :paramtype post_task: ~azure.mgmt.automation.models.TaskProperties + """ super(SoftwareUpdateConfigurationTasks, self).__init__(**kwargs) self.pre_task = pre_task self.post_task = post_task -class SourceControl(Resource): +class SourceControl(ProxyResource): """Definition of the source control. Variables are only populated by the server, and will be ignored when sending a request. @@ -5180,26 +7224,26 @@ class SourceControl(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for + :ivar repo_url: The repo url of the source control. + :vartype repo_url: str + :ivar branch: The repo branch of the source control. Include branch as empty string for VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub. Possible values - include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param description: The description. - :type description: str - :param creation_time: The creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: The last modified time. - :type last_modified_time: ~datetime.datetime + :vartype branch: str + :ivar folder_path: The folder path of the source control. + :vartype folder_path: str + :ivar auto_sync: The auto sync of the source control. Default is false. + :vartype auto_sync: bool + :ivar publish_runbook: The auto publish of the source control. Default is true. + :vartype publish_runbook: bool + :ivar source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub. Known values are: + "VsoGit", "VsoTfvc", "GitHub". + :vartype source_type: str or ~azure.mgmt.automation.models.SourceType + :ivar description: The description. + :vartype description: str + :ivar creation_time: The creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: The last modified time. + :vartype last_modified_time: ~datetime.datetime """ _validation = { @@ -5231,12 +7275,34 @@ def __init__( folder_path: Optional[str] = None, auto_sync: Optional[bool] = None, publish_runbook: Optional[bool] = None, - source_type: Optional[Union[str, "SourceType"]] = None, + source_type: Optional[Union[str, "_models.SourceType"]] = None, description: Optional[str] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword repo_url: The repo url of the source control. + :paramtype repo_url: str + :keyword branch: The repo branch of the source control. Include branch as empty string for + VsoTfvc. + :paramtype branch: str + :keyword folder_path: The folder path of the source control. + :paramtype folder_path: str + :keyword auto_sync: The auto sync of the source control. Default is false. + :paramtype auto_sync: bool + :keyword publish_runbook: The auto publish of the source control. Default is true. + :paramtype publish_runbook: bool + :keyword source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub. Known values + are: "VsoGit", "VsoTfvc", "GitHub". + :paramtype source_type: str or ~azure.mgmt.automation.models.SourceType + :keyword description: The description. + :paramtype description: str + :keyword creation_time: The creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: The last modified time. + :paramtype last_modified_time: ~datetime.datetime + """ super(SourceControl, self).__init__(**kwargs) self.repo_url = repo_url self.branch = branch @@ -5252,24 +7318,24 @@ def __init__( class SourceControlCreateOrUpdateParameters(msrest.serialization.Model): """The parameters supplied to the create or update source control operation. - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for + :ivar repo_url: The repo url of the source control. + :vartype repo_url: str + :ivar branch: The repo branch of the source control. Include branch as empty string for VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto async of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. - Possible values include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str + :vartype branch: str + :ivar folder_path: The folder path of the source control. Path must be relative. + :vartype folder_path: str + :ivar auto_sync: The auto async of the source control. Default is false. + :vartype auto_sync: bool + :ivar publish_runbook: The auto publish of the source control. Default is true. + :vartype publish_runbook: bool + :ivar source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. + Known values are: "VsoGit", "VsoTfvc", "GitHub". + :vartype source_type: str or ~azure.mgmt.automation.models.SourceType + :ivar security_token: The authorization token for the repo of the source control. + :vartype security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties + :ivar description: The user description of the source control. + :vartype description: str """ _validation = { @@ -5298,11 +7364,31 @@ def __init__( folder_path: Optional[str] = None, auto_sync: Optional[bool] = None, publish_runbook: Optional[bool] = None, - source_type: Optional[Union[str, "SourceType"]] = None, - security_token: Optional["SourceControlSecurityTokenProperties"] = None, + source_type: Optional[Union[str, "_models.SourceType"]] = None, + security_token: Optional["_models.SourceControlSecurityTokenProperties"] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword repo_url: The repo url of the source control. + :paramtype repo_url: str + :keyword branch: The repo branch of the source control. Include branch as empty string for + VsoTfvc. + :paramtype branch: str + :keyword folder_path: The folder path of the source control. Path must be relative. + :paramtype folder_path: str + :keyword auto_sync: The auto async of the source control. Default is false. + :paramtype auto_sync: bool + :keyword publish_runbook: The auto publish of the source control. Default is true. + :paramtype publish_runbook: bool + :keyword source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. + Known values are: "VsoGit", "VsoTfvc", "GitHub". + :paramtype source_type: str or ~azure.mgmt.automation.models.SourceType + :keyword security_token: The authorization token for the repo of the source control. + :paramtype security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties + :keyword description: The user description of the source control. + :paramtype description: str + """ super(SourceControlCreateOrUpdateParameters, self).__init__(**kwargs) self.repo_url = repo_url self.branch = branch @@ -5317,10 +7403,10 @@ def __init__( class SourceControlListResult(msrest.serialization.Model): """The response model for the list source controls operation. - :param value: The list of source controls. - :type value: list[~azure.mgmt.automation.models.SourceControl] - :param next_link: The next link. - :type next_link: str + :ivar value: The list of source controls. + :vartype value: list[~azure.mgmt.automation.models.SourceControl] + :ivar next_link: The next link. + :vartype next_link: str """ _attribute_map = { @@ -5331,10 +7417,16 @@ class SourceControlListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SourceControl"]] = None, + value: Optional[List["_models.SourceControl"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of source controls. + :paramtype value: list[~azure.mgmt.automation.models.SourceControl] + :keyword next_link: The next link. + :paramtype next_link: str + """ super(SourceControlListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5343,13 +7435,13 @@ def __init__( class SourceControlSecurityTokenProperties(msrest.serialization.Model): """SourceControlSecurityTokenProperties. - :param access_token: The access token. - :type access_token: str - :param refresh_token: The refresh token. - :type refresh_token: str - :param token_type: The token type. Must be either PersonalAccessToken or Oauth. Possible values - include: "PersonalAccessToken", "Oauth". - :type token_type: str or ~azure.mgmt.automation.models.TokenType + :ivar access_token: The access token. + :vartype access_token: str + :ivar refresh_token: The refresh token. + :vartype refresh_token: str + :ivar token_type: The token type. Must be either PersonalAccessToken or Oauth. Known values + are: "PersonalAccessToken", "Oauth". + :vartype token_type: str or ~azure.mgmt.automation.models.TokenType """ _validation = { @@ -5368,9 +7460,18 @@ def __init__( *, access_token: Optional[str] = None, refresh_token: Optional[str] = None, - token_type: Optional[Union[str, "TokenType"]] = None, - **kwargs - ): + token_type: Optional[Union[str, "_models.TokenType"]] = None, + **kwargs + ): + """ + :keyword access_token: The access token. + :paramtype access_token: str + :keyword refresh_token: The refresh token. + :paramtype refresh_token: str + :keyword token_type: The token type. Must be either PersonalAccessToken or Oauth. Known values + are: "PersonalAccessToken", "Oauth". + :paramtype token_type: str or ~azure.mgmt.automation.models.TokenType + """ super(SourceControlSecurityTokenProperties, self).__init__(**kwargs) self.access_token = access_token self.refresh_token = refresh_token @@ -5388,19 +7489,19 @@ class SourceControlSyncJob(msrest.serialization.Model): :vartype type: str :ivar id: Resource id. :vartype id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str + :ivar source_control_sync_job_id: The source control sync job id. + :vartype source_control_sync_job_id: str :ivar creation_time: The creation time of the job. :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :ivar provisioning_state: The provisioning state of the job. Known values are: "Completed", + "Failed", "Running". + :vartype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState :ivar start_time: The start time of the job. :vartype start_time: ~datetime.datetime :ivar end_time: The end time of the job. :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType + :ivar sync_type: The sync type. Known values are: "PartialSync", "FullSync". + :vartype sync_type: str or ~azure.mgmt.automation.models.SyncType """ _validation = { @@ -5428,10 +7529,19 @@ def __init__( self, *, source_control_sync_job_id: Optional[str] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - sync_type: Optional[Union[str, "SyncType"]] = None, - **kwargs - ): + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + sync_type: Optional[Union[str, "_models.SyncType"]] = None, + **kwargs + ): + """ + :keyword source_control_sync_job_id: The source control sync job id. + :paramtype source_control_sync_job_id: str + :keyword provisioning_state: The provisioning state of the job. Known values are: "Completed", + "Failed", "Running". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :keyword sync_type: The sync type. Known values are: "PartialSync", "FullSync". + :paramtype sync_type: str or ~azure.mgmt.automation.models.SyncType + """ super(SourceControlSyncJob, self).__init__(**kwargs) self.name = None self.type = None @@ -5449,23 +7559,23 @@ class SourceControlSyncJobById(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: The id of the job. - :type id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str + :ivar id: The id of the job. + :vartype id: str + :ivar source_control_sync_job_id: The source control sync job id. + :vartype source_control_sync_job_id: str :ivar creation_time: The creation time of the job. :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :ivar provisioning_state: The provisioning state of the job. Known values are: "Completed", + "Failed", "Running". + :vartype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState :ivar start_time: The start time of the job. :vartype start_time: ~datetime.datetime :ivar end_time: The end time of the job. :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType - :param exception: The exceptions that occurred while running the sync job. - :type exception: str + :ivar sync_type: The sync type. Known values are: "PartialSync", "FullSync". + :vartype sync_type: str or ~azure.mgmt.automation.models.SyncType + :ivar exception: The exceptions that occurred while running the sync job. + :vartype exception: str """ _validation = { @@ -5490,11 +7600,24 @@ def __init__( *, id: Optional[str] = None, source_control_sync_job_id: Optional[str] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - sync_type: Optional[Union[str, "SyncType"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + sync_type: Optional[Union[str, "_models.SyncType"]] = None, exception: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the job. + :paramtype id: str + :keyword source_control_sync_job_id: The source control sync job id. + :paramtype source_control_sync_job_id: str + :keyword provisioning_state: The provisioning state of the job. Known values are: "Completed", + "Failed", "Running". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :keyword sync_type: The sync type. Known values are: "PartialSync", "FullSync". + :paramtype sync_type: str or ~azure.mgmt.automation.models.SyncType + :keyword exception: The exceptions that occurred while running the sync job. + :paramtype exception: str + """ super(SourceControlSyncJobById, self).__init__(**kwargs) self.id = id self.source_control_sync_job_id = source_control_sync_job_id @@ -5511,9 +7634,9 @@ class SourceControlSyncJobCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param commit_id: Required. The commit id of the source control sync job. If not syncing to a + :ivar commit_id: Required. The commit id of the source control sync job. If not syncing to a commitId, enter an empty string. - :type commit_id: str + :vartype commit_id: str """ _validation = { @@ -5530,6 +7653,11 @@ def __init__( commit_id: str, **kwargs ): + """ + :keyword commit_id: Required. The commit id of the source control sync job. If not syncing to a + commitId, enter an empty string. + :paramtype commit_id: str + """ super(SourceControlSyncJobCreateParameters, self).__init__(**kwargs) self.commit_id = commit_id @@ -5537,10 +7665,10 @@ def __init__( class SourceControlSyncJobListResult(msrest.serialization.Model): """The response model for the list source control sync jobs operation. - :param value: The list of source control sync jobs. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJob] - :param next_link: The next link. - :type next_link: str + :ivar value: The list of source control sync jobs. + :vartype value: list[~azure.mgmt.automation.models.SourceControlSyncJob] + :ivar next_link: The next link. + :vartype next_link: str """ _attribute_map = { @@ -5551,10 +7679,16 @@ class SourceControlSyncJobListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SourceControlSyncJob"]] = None, + value: Optional[List["_models.SourceControlSyncJob"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of source control sync jobs. + :paramtype value: list[~azure.mgmt.automation.models.SourceControlSyncJob] + :keyword next_link: The next link. + :paramtype next_link: str + """ super(SourceControlSyncJobListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5567,15 +7701,14 @@ class SourceControlSyncJobStream(msrest.serialization.Model): :ivar id: Resource id. :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str + :ivar source_control_sync_job_stream_id: The sync job stream id. + :vartype source_control_sync_job_stream_id: str + :ivar summary: The summary of the sync job stream. + :vartype summary: str :ivar time: The time of the sync job stream. :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType + :ivar stream_type: The type of the sync job stream. Known values are: "Error", "Output". + :vartype stream_type: str or ~azure.mgmt.automation.models.StreamType """ _validation = { @@ -5596,9 +7729,17 @@ def __init__( *, source_control_sync_job_stream_id: Optional[str] = None, summary: Optional[str] = None, - stream_type: Optional[Union[str, "StreamType"]] = None, + stream_type: Optional[Union[str, "_models.StreamType"]] = None, **kwargs ): + """ + :keyword source_control_sync_job_stream_id: The sync job stream id. + :paramtype source_control_sync_job_stream_id: str + :keyword summary: The summary of the sync job stream. + :paramtype summary: str + :keyword stream_type: The type of the sync job stream. Known values are: "Error", "Output". + :paramtype stream_type: str or ~azure.mgmt.automation.models.StreamType + """ super(SourceControlSyncJobStream, self).__init__(**kwargs) self.id = None self.source_control_sync_job_stream_id = source_control_sync_job_stream_id @@ -5614,19 +7755,18 @@ class SourceControlSyncJobStreamById(msrest.serialization.Model): :ivar id: Resource id. :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str + :ivar source_control_sync_job_stream_id: The sync job stream id. + :vartype source_control_sync_job_stream_id: str + :ivar summary: The summary of the sync job stream. + :vartype summary: str :ivar time: The time of the sync job stream. :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType - :param stream_text: The text of the sync job stream. - :type stream_text: str - :param value: The values of the job stream. - :type value: dict[str, object] + :ivar stream_type: The type of the sync job stream. Known values are: "Error", "Output". + :vartype stream_type: str or ~azure.mgmt.automation.models.StreamType + :ivar stream_text: The text of the sync job stream. + :vartype stream_text: str + :ivar value: The values of the job stream. + :vartype value: dict[str, any] """ _validation = { @@ -5649,11 +7789,23 @@ def __init__( *, source_control_sync_job_stream_id: Optional[str] = None, summary: Optional[str] = None, - stream_type: Optional[Union[str, "StreamType"]] = None, + stream_type: Optional[Union[str, "_models.StreamType"]] = None, stream_text: Optional[str] = None, - value: Optional[Dict[str, object]] = None, - **kwargs - ): + value: Optional[Dict[str, Any]] = None, + **kwargs + ): + """ + :keyword source_control_sync_job_stream_id: The sync job stream id. + :paramtype source_control_sync_job_stream_id: str + :keyword summary: The summary of the sync job stream. + :paramtype summary: str + :keyword stream_type: The type of the sync job stream. Known values are: "Error", "Output". + :paramtype stream_type: str or ~azure.mgmt.automation.models.StreamType + :keyword stream_text: The text of the sync job stream. + :paramtype stream_text: str + :keyword value: The values of the job stream. + :paramtype value: dict[str, any] + """ super(SourceControlSyncJobStreamById, self).__init__(**kwargs) self.id = None self.source_control_sync_job_stream_id = source_control_sync_job_stream_id @@ -5669,8 +7821,8 @@ class SourceControlSyncJobStreamsListBySyncJob(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of source control sync job streams. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] + :ivar value: The list of source control sync job streams. + :vartype value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] :ivar next_link: The next link. :vartype next_link: str """ @@ -5687,9 +7839,13 @@ class SourceControlSyncJobStreamsListBySyncJob(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SourceControlSyncJobStream"]] = None, + value: Optional[List["_models.SourceControlSyncJobStream"]] = None, **kwargs ): + """ + :keyword value: The list of source control sync job streams. + :paramtype value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] + """ super(SourceControlSyncJobStreamsListBySyncJob, self).__init__(**kwargs) self.value = value self.next_link = None @@ -5698,18 +7854,18 @@ def __init__( class SourceControlUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update source control operation. - :param branch: The repo branch of the source control. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str + :ivar branch: The repo branch of the source control. + :vartype branch: str + :ivar folder_path: The folder path of the source control. Path must be relative. + :vartype folder_path: str + :ivar auto_sync: The auto sync of the source control. Default is false. + :vartype auto_sync: bool + :ivar publish_runbook: The auto publish of the source control. Default is true. + :vartype publish_runbook: bool + :ivar security_token: The authorization token for the repo of the source control. + :vartype security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties + :ivar description: The user description of the source control. + :vartype description: str """ _attribute_map = { @@ -5728,10 +7884,24 @@ def __init__( folder_path: Optional[str] = None, auto_sync: Optional[bool] = None, publish_runbook: Optional[bool] = None, - security_token: Optional["SourceControlSecurityTokenProperties"] = None, + security_token: Optional["_models.SourceControlSecurityTokenProperties"] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword branch: The repo branch of the source control. + :paramtype branch: str + :keyword folder_path: The folder path of the source control. Path must be relative. + :paramtype folder_path: str + :keyword auto_sync: The auto sync of the source control. Default is false. + :paramtype auto_sync: bool + :keyword publish_runbook: The auto publish of the source control. Default is true. + :paramtype publish_runbook: bool + :keyword security_token: The authorization token for the repo of the source control. + :paramtype security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties + :keyword description: The user description of the source control. + :paramtype description: str + """ super(SourceControlUpdateParameters, self).__init__(**kwargs) self.branch = branch self.folder_path = folder_path @@ -5778,6 +7948,8 @@ def __init__( self, **kwargs ): + """ + """ super(Statistics, self).__init__(**kwargs) self.counter_property = None self.counter_value = None @@ -5789,8 +7961,8 @@ def __init__( class StatisticsListResult(msrest.serialization.Model): """The response model for the list statistics operation. - :param value: Gets or sets a list of statistics. - :type value: list[~azure.mgmt.automation.models.Statistics] + :ivar value: Gets or sets a list of statistics. + :vartype value: list[~azure.mgmt.automation.models.Statistics] """ _attribute_map = { @@ -5800,9 +7972,13 @@ class StatisticsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Statistics"]] = None, + value: Optional[List["_models.Statistics"]] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of statistics. + :paramtype value: list[~azure.mgmt.automation.models.Statistics] + """ super(StatisticsListResult, self).__init__(**kwargs) self.value = value @@ -5812,35 +7988,35 @@ class SUCScheduleProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime + :ivar start_time: Gets or sets the start time of the schedule. + :vartype start_time: ~datetime.datetime :ivar start_time_offset_minutes: Gets the start time's offset in minutes. :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: long - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar expiry_time: Gets or sets the end time of the schedule. + :vartype expiry_time: ~datetime.datetime + :ivar expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. + :vartype expiry_time_offset_minutes: float + :ivar is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :vartype is_enabled: bool + :ivar next_run: Gets or sets the next run time of the schedule. + :vartype next_run: ~datetime.datetime + :ivar next_run_offset_minutes: Gets or sets the next run time's offset in minutes. + :vartype next_run_offset_minutes: float + :ivar interval: Gets or sets the interval of the schedule. + :vartype interval: long + :ivar frequency: Gets or sets the frequency of the schedule. Known values are: "OneTime", + "Day", "Hour", "Week", "Month", "Minute". + :vartype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :ivar time_zone: Gets or sets the time zone of the schedule. + :vartype time_zone: str + :ivar advanced_schedule: Gets or sets the advanced schedule. + :vartype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -5874,14 +8050,43 @@ def __init__( next_run: Optional[datetime.datetime] = None, next_run_offset_minutes: Optional[float] = None, interval: Optional[int] = None, - frequency: Optional[Union[str, "ScheduleFrequency"]] = None, + frequency: Optional[Union[str, "_models.ScheduleFrequency"]] = None, time_zone: Optional[str] = None, - advanced_schedule: Optional["AdvancedSchedule"] = None, + advanced_schedule: Optional["_models.AdvancedSchedule"] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, description: Optional[str] = None, **kwargs ): + """ + :keyword start_time: Gets or sets the start time of the schedule. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Gets or sets the end time of the schedule. + :paramtype expiry_time: ~datetime.datetime + :keyword expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. + :paramtype expiry_time_offset_minutes: float + :keyword is_enabled: Gets or sets a value indicating whether this schedule is enabled. + :paramtype is_enabled: bool + :keyword next_run: Gets or sets the next run time of the schedule. + :paramtype next_run: ~datetime.datetime + :keyword next_run_offset_minutes: Gets or sets the next run time's offset in minutes. + :paramtype next_run_offset_minutes: float + :keyword interval: Gets or sets the interval of the schedule. + :paramtype interval: long + :keyword frequency: Gets or sets the frequency of the schedule. Known values are: "OneTime", + "Day", "Hour", "Week", "Month", "Minute". + :paramtype frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency + :keyword time_zone: Gets or sets the time zone of the schedule. + :paramtype time_zone: str + :keyword advanced_schedule: Gets or sets the advanced schedule. + :paramtype advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(SUCScheduleProperties, self).__init__(**kwargs) self.start_time = start_time self.start_time_offset_minutes = None @@ -5899,14 +8104,77 @@ def __init__( self.description = description +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.automation.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.automation.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.automation.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.automation.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TagSettingsProperties(msrest.serialization.Model): """Tag filter information for the VM. - :param tags: A set of tags. Dictionary of tags with its list of values. - :type tags: dict[str, list[str]] - :param filter_operator: Filter VMs by Any or All specified tags. Possible values include: - "All", "Any". - :type filter_operator: str or ~azure.mgmt.automation.models.TagOperators + :ivar tags: A set of tags. Dictionary of tags with its list of values. + :vartype tags: dict[str, list[str]] + :ivar filter_operator: Filter VMs by Any or All specified tags. Known values are: "All", "Any". + :vartype filter_operator: str or ~azure.mgmt.automation.models.TagOperators """ _attribute_map = { @@ -5918,9 +8186,16 @@ def __init__( self, *, tags: Optional[Dict[str, List[str]]] = None, - filter_operator: Optional[Union[str, "TagOperators"]] = None, + filter_operator: Optional[Union[str, "_models.TagOperators"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Dictionary of tags with its list of values. + :paramtype tags: dict[str, list[str]] + :keyword filter_operator: Filter VMs by Any or All specified tags. Known values are: "All", + "Any". + :paramtype filter_operator: str or ~azure.mgmt.automation.models.TagOperators + """ super(TagSettingsProperties, self).__init__(**kwargs) self.tags = tags self.filter_operator = filter_operator @@ -5929,10 +8204,10 @@ def __init__( class TargetProperties(msrest.serialization.Model): """Group specific to the update configuration. - :param azure_queries: List of Azure queries in the software update configuration. - :type azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] - :param non_azure_queries: List of non Azure queries in the software update configuration. - :type non_azure_queries: list[~azure.mgmt.automation.models.NonAzureQueryProperties] + :ivar azure_queries: List of Azure queries in the software update configuration. + :vartype azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] + :ivar non_azure_queries: List of non Azure queries in the software update configuration. + :vartype non_azure_queries: list[~azure.mgmt.automation.models.NonAzureQueryProperties] """ _attribute_map = { @@ -5943,10 +8218,16 @@ class TargetProperties(msrest.serialization.Model): def __init__( self, *, - azure_queries: Optional[List["AzureQueryProperties"]] = None, - non_azure_queries: Optional[List["NonAzureQueryProperties"]] = None, + azure_queries: Optional[List["_models.AzureQueryProperties"]] = None, + non_azure_queries: Optional[List["_models.NonAzureQueryProperties"]] = None, **kwargs ): + """ + :keyword azure_queries: List of Azure queries in the software update configuration. + :paramtype azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] + :keyword non_azure_queries: List of non Azure queries in the software update configuration. + :paramtype non_azure_queries: list[~azure.mgmt.automation.models.NonAzureQueryProperties] + """ super(TargetProperties, self).__init__(**kwargs) self.azure_queries = azure_queries self.non_azure_queries = non_azure_queries @@ -5955,10 +8236,10 @@ def __init__( class TaskProperties(msrest.serialization.Model): """Task properties of the software update configuration. - :param parameters: Gets or sets the parameters of the task. - :type parameters: dict[str, str] - :param source: Gets or sets the name of the runbook. - :type source: str + :ivar parameters: Gets or sets the parameters of the task. + :vartype parameters: dict[str, str] + :ivar source: Gets or sets the name of the runbook. + :vartype source: str """ _attribute_map = { @@ -5973,6 +8254,12 @@ def __init__( source: Optional[str] = None, **kwargs ): + """ + :keyword parameters: Gets or sets the parameters of the task. + :paramtype parameters: dict[str, str] + :keyword source: Gets or sets the name of the runbook. + :paramtype source: str + """ super(TaskProperties, self).__init__(**kwargs) self.parameters = parameters self.source = source @@ -5981,29 +8268,29 @@ def __init__( class TestJob(msrest.serialization.Model): """Definition of the test job. - :param creation_time: Gets or sets the creation time of the test job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the test job. - :type status: str - :param status_details: Gets or sets the status details of the test job. - :type status_details: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be + :ivar creation_time: Gets or sets the creation time of the test job. + :vartype creation_time: ~datetime.datetime + :ivar status: Gets or sets the status of the test job. + :vartype status: str + :ivar status_details: Gets or sets the status details of the test job. + :vartype status_details: str + :ivar run_on: Gets or sets the runOn which specifies the group name where the job is to be executed. - :type run_on: str - :param start_time: Gets or sets the start time of the test job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the test job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the test job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the test job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the test job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param log_activity_trace: The activity-level tracing options of the runbook. - :type log_activity_trace: int + :vartype run_on: str + :ivar start_time: Gets or sets the start time of the test job. + :vartype start_time: ~datetime.datetime + :ivar end_time: Gets or sets the end time of the test job. + :vartype end_time: ~datetime.datetime + :ivar exception: Gets or sets the exception of the test job. + :vartype exception: str + :ivar last_modified_time: Gets or sets the last modified time of the test job. + :vartype last_modified_time: ~datetime.datetime + :ivar last_status_modified_time: Gets or sets the last status modified time of the test job. + :vartype last_status_modified_time: ~datetime.datetime + :ivar parameters: Gets or sets the parameters of the test job. + :vartype parameters: dict[str, str] + :ivar log_activity_trace: The activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _attribute_map = { @@ -6036,6 +8323,31 @@ def __init__( log_activity_trace: Optional[int] = None, **kwargs ): + """ + :keyword creation_time: Gets or sets the creation time of the test job. + :paramtype creation_time: ~datetime.datetime + :keyword status: Gets or sets the status of the test job. + :paramtype status: str + :keyword status_details: Gets or sets the status details of the test job. + :paramtype status_details: str + :keyword run_on: Gets or sets the runOn which specifies the group name where the job is to be + executed. + :paramtype run_on: str + :keyword start_time: Gets or sets the start time of the test job. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Gets or sets the end time of the test job. + :paramtype end_time: ~datetime.datetime + :keyword exception: Gets or sets the exception of the test job. + :paramtype exception: str + :keyword last_modified_time: Gets or sets the last modified time of the test job. + :paramtype last_modified_time: ~datetime.datetime + :keyword last_status_modified_time: Gets or sets the last status modified time of the test job. + :paramtype last_status_modified_time: ~datetime.datetime + :keyword parameters: Gets or sets the parameters of the test job. + :paramtype parameters: dict[str, str] + :keyword log_activity_trace: The activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(TestJob, self).__init__(**kwargs) self.creation_time = creation_time self.status = status @@ -6053,11 +8365,11 @@ def __init__( class TestJobCreateParameters(msrest.serialization.Model): """The parameters supplied to the create test job operation. - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be + :ivar parameters: Gets or sets the parameters of the test job. + :vartype parameters: dict[str, str] + :ivar run_on: Gets or sets the runOn which specifies the group name where the job is to be executed. - :type run_on: str + :vartype run_on: str """ _attribute_map = { @@ -6072,6 +8384,13 @@ def __init__( run_on: Optional[str] = None, **kwargs ): + """ + :keyword parameters: Gets or sets the parameters of the test job. + :paramtype parameters: dict[str, str] + :keyword run_on: Gets or sets the runOn which specifies the group name where the job is to be + executed. + :paramtype run_on: str + """ super(TestJobCreateParameters, self).__init__(**kwargs) self.parameters = parameters self.run_on = run_on @@ -6080,10 +8399,10 @@ def __init__( class TypeField(msrest.serialization.Model): """Information about a field of a type. - :param name: Gets or sets the name of the field. - :type name: str - :param type: Gets or sets the type of the field. - :type type: str + :ivar name: Gets or sets the name of the field. + :vartype name: str + :ivar type: Gets or sets the type of the field. + :vartype type: str """ _attribute_map = { @@ -6098,6 +8417,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the field. + :paramtype name: str + :keyword type: Gets or sets the type of the field. + :paramtype type: str + """ super(TypeField, self).__init__(**kwargs) self.name = name self.type = type @@ -6106,8 +8431,8 @@ def __init__( class TypeFieldListResult(msrest.serialization.Model): """The response model for the list fields operation. - :param value: Gets or sets a list of fields. - :type value: list[~azure.mgmt.automation.models.TypeField] + :ivar value: Gets or sets a list of fields. + :vartype value: list[~azure.mgmt.automation.models.TypeField] """ _attribute_map = { @@ -6117,9 +8442,13 @@ class TypeFieldListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["TypeField"]] = None, + value: Optional[List["_models.TypeField"]] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of fields. + :paramtype value: list[~azure.mgmt.automation.models.TypeField] + """ super(TypeFieldListResult, self).__init__(**kwargs) self.value = value @@ -6129,24 +8458,24 @@ class UpdateConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param operating_system: Required. operating system of target machines. Possible values - include: "Windows", "Linux". - :type operating_system: str or ~azure.mgmt.automation.models.OperatingSystemType - :param windows: Windows specific update configuration. - :type windows: ~azure.mgmt.automation.models.WindowsProperties - :param linux: Linux specific update configuration. - :type linux: ~azure.mgmt.automation.models.LinuxProperties - :param duration: Maximum time allowed for the software update configuration run. Duration needs + :ivar operating_system: Required. operating system of target machines. Known values are: + "Windows", "Linux". + :vartype operating_system: str or ~azure.mgmt.automation.models.OperatingSystemType + :ivar windows: Windows specific update configuration. + :vartype windows: ~azure.mgmt.automation.models.WindowsProperties + :ivar linux: Linux specific update configuration. + :vartype linux: ~azure.mgmt.automation.models.LinuxProperties + :ivar duration: Maximum time allowed for the software update configuration run. Duration needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601. - :type duration: ~datetime.timedelta - :param azure_virtual_machines: List of azure resource Ids for azure virtual machines targeted - by the software update configuration. - :type azure_virtual_machines: list[str] - :param non_azure_computer_names: List of names of non-azure machines targeted by the software + :vartype duration: ~datetime.timedelta + :ivar azure_virtual_machines: List of azure resource Ids for azure virtual machines targeted by + the software update configuration. + :vartype azure_virtual_machines: list[str] + :ivar non_azure_computer_names: List of names of non-azure machines targeted by the software update configuration. - :type non_azure_computer_names: list[str] - :param targets: Group targets for the software update configuration. - :type targets: ~azure.mgmt.automation.models.TargetProperties + :vartype non_azure_computer_names: list[str] + :ivar targets: Group targets for the software update configuration. + :vartype targets: ~azure.mgmt.automation.models.TargetProperties """ _validation = { @@ -6166,15 +8495,35 @@ class UpdateConfiguration(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemType"], - windows: Optional["WindowsProperties"] = None, - linux: Optional["LinuxProperties"] = None, + operating_system: Union[str, "_models.OperatingSystemType"], + windows: Optional["_models.WindowsProperties"] = None, + linux: Optional["_models.LinuxProperties"] = None, duration: Optional[datetime.timedelta] = None, azure_virtual_machines: Optional[List[str]] = None, non_azure_computer_names: Optional[List[str]] = None, - targets: Optional["TargetProperties"] = None, - **kwargs - ): + targets: Optional["_models.TargetProperties"] = None, + **kwargs + ): + """ + :keyword operating_system: Required. operating system of target machines. Known values are: + "Windows", "Linux". + :paramtype operating_system: str or ~azure.mgmt.automation.models.OperatingSystemType + :keyword windows: Windows specific update configuration. + :paramtype windows: ~azure.mgmt.automation.models.WindowsProperties + :keyword linux: Linux specific update configuration. + :paramtype linux: ~azure.mgmt.automation.models.LinuxProperties + :keyword duration: Maximum time allowed for the software update configuration run. Duration + needs to be specified using the format PT[n]H[n]M[n]S as per ISO8601. + :paramtype duration: ~datetime.timedelta + :keyword azure_virtual_machines: List of azure resource Ids for azure virtual machines targeted + by the software update configuration. + :paramtype azure_virtual_machines: list[str] + :keyword non_azure_computer_names: List of names of non-azure machines targeted by the software + update configuration. + :paramtype non_azure_computer_names: list[str] + :keyword targets: Group targets for the software update configuration. + :paramtype targets: ~azure.mgmt.automation.models.TargetProperties + """ super(UpdateConfiguration, self).__init__(**kwargs) self.operating_system = operating_system self.windows = windows @@ -6207,6 +8556,8 @@ def __init__( self, **kwargs ): + """ + """ super(UpdateConfigurationNavigation, self).__init__(**kwargs) self.name = None @@ -6214,18 +8565,18 @@ def __init__( class Usage(msrest.serialization.Model): """Definition of Usage. - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the usage counter name. - :type name: ~azure.mgmt.automation.models.UsageCounterName - :param unit: Gets or sets the usage unit name. - :type unit: str - :param current_value: Gets or sets the current usage value. - :type current_value: float - :param limit: Gets or sets max limit. -1 for unlimited. - :type limit: long - :param throttle_status: Gets or sets the throttle status. - :type throttle_status: str + :ivar id: Gets or sets the id of the resource. + :vartype id: str + :ivar name: Gets or sets the usage counter name. + :vartype name: ~azure.mgmt.automation.models.UsageCounterName + :ivar unit: Gets or sets the usage unit name. + :vartype unit: str + :ivar current_value: Gets or sets the current usage value. + :vartype current_value: float + :ivar limit: Gets or sets max limit. -1 for unlimited. + :vartype limit: long + :ivar throttle_status: Gets or sets the throttle status. + :vartype throttle_status: str """ _attribute_map = { @@ -6241,13 +8592,27 @@ def __init__( self, *, id: Optional[str] = None, - name: Optional["UsageCounterName"] = None, + name: Optional["_models.UsageCounterName"] = None, unit: Optional[str] = None, current_value: Optional[float] = None, limit: Optional[int] = None, throttle_status: Optional[str] = None, **kwargs ): + """ + :keyword id: Gets or sets the id of the resource. + :paramtype id: str + :keyword name: Gets or sets the usage counter name. + :paramtype name: ~azure.mgmt.automation.models.UsageCounterName + :keyword unit: Gets or sets the usage unit name. + :paramtype unit: str + :keyword current_value: Gets or sets the current usage value. + :paramtype current_value: float + :keyword limit: Gets or sets max limit. -1 for unlimited. + :paramtype limit: long + :keyword throttle_status: Gets or sets the throttle status. + :paramtype throttle_status: str + """ super(Usage, self).__init__(**kwargs) self.id = id self.name = name @@ -6260,10 +8625,10 @@ def __init__( class UsageCounterName(msrest.serialization.Model): """Definition of usage counter name. - :param value: Gets or sets the usage counter name. - :type value: str - :param localized_value: Gets or sets the localized usage counter name. - :type localized_value: str + :ivar value: Gets or sets the usage counter name. + :vartype value: str + :ivar localized_value: Gets or sets the localized usage counter name. + :vartype localized_value: str """ _attribute_map = { @@ -6278,6 +8643,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets the usage counter name. + :paramtype value: str + :keyword localized_value: Gets or sets the localized usage counter name. + :paramtype localized_value: str + """ super(UsageCounterName, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -6286,8 +8657,8 @@ def __init__( class UsageListResult(msrest.serialization.Model): """The response model for the get usage operation. - :param value: Gets or sets usage. - :type value: list[~azure.mgmt.automation.models.Usage] + :ivar value: Gets or sets usage. + :vartype value: list[~azure.mgmt.automation.models.Usage] """ _attribute_map = { @@ -6297,14 +8668,18 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): + """ + :keyword value: Gets or sets usage. + :paramtype value: list[~azure.mgmt.automation.models.Usage] + """ super(UsageListResult, self).__init__(**kwargs) self.value = value -class Variable(Resource): +class Variable(ProxyResource): """Definition of the variable. Variables are only populated by the server, and will be ignored when sending a request. @@ -6315,16 +8690,16 @@ class Variable(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param value: Gets or sets the value of the variable. - :type value: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str + :ivar value: Gets or sets the value of the variable. + :vartype value: str + :ivar is_encrypted: Gets or sets the encrypted flag of the variable. + :vartype is_encrypted: bool + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -6354,6 +8729,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets the value of the variable. + :paramtype value: str + :keyword is_encrypted: Gets or sets the encrypted flag of the variable. + :paramtype is_encrypted: bool + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Variable, self).__init__(**kwargs) self.value = value self.is_encrypted = is_encrypted @@ -6367,14 +8754,14 @@ class VariableCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool + :ivar name: Required. Gets or sets the name of the variable. + :vartype name: str + :ivar value: Gets or sets the value of the variable. + :vartype value: str + :ivar description: Gets or sets the description of the variable. + :vartype description: str + :ivar is_encrypted: Gets or sets the encrypted flag of the variable. + :vartype is_encrypted: bool """ _validation = { @@ -6397,6 +8784,16 @@ def __init__( is_encrypted: Optional[bool] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the variable. + :paramtype name: str + :keyword value: Gets or sets the value of the variable. + :paramtype value: str + :keyword description: Gets or sets the description of the variable. + :paramtype description: str + :keyword is_encrypted: Gets or sets the encrypted flag of the variable. + :paramtype is_encrypted: bool + """ super(VariableCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.value = value @@ -6407,10 +8804,10 @@ def __init__( class VariableListResult(msrest.serialization.Model): """The response model for the list variables operation. - :param value: Gets or sets a list of variables. - :type value: list[~azure.mgmt.automation.models.Variable] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of variables. + :vartype value: list[~azure.mgmt.automation.models.Variable] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -6421,10 +8818,16 @@ class VariableListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Variable"]] = None, + value: Optional[List["_models.Variable"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of variables. + :paramtype value: list[~azure.mgmt.automation.models.Variable] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(VariableListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6433,12 +8836,12 @@ def __init__( class VariableUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update variable operation. - :param name: Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str + :ivar name: Gets or sets the name of the variable. + :vartype name: str + :ivar value: Gets or sets the value of the variable. + :vartype value: str + :ivar description: Gets or sets the description of the variable. + :vartype description: str """ _attribute_map = { @@ -6455,6 +8858,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the variable. + :paramtype name: str + :keyword value: Gets or sets the value of the variable. + :paramtype value: str + :keyword description: Gets or sets the description of the variable. + :paramtype description: str + """ super(VariableUpdateParameters, self).__init__(**kwargs) self.name = name self.value = value @@ -6472,22 +8883,22 @@ class Watcher(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The geo-location where the resource lives. - :type location: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is invoked. - :type execution_frequency_in_seconds: long - :param script_name: Gets or sets the name of the script the watcher is attached to, i.e. the + :vartype execution_frequency_in_seconds: long + :ivar script_name: Gets or sets the name of the script the watcher is attached to, i.e. the name of an existing runbook. - :type script_name: str - :param script_parameters: Gets or sets the parameters of the script. - :type script_parameters: dict[str, str] - :param script_run_on: Gets or sets the name of the hybrid worker group the watcher will run on. - :type script_run_on: str + :vartype script_name: str + :ivar script_parameters: Gets or sets the parameters of the script. + :vartype script_parameters: dict[str, str] + :ivar script_run_on: Gets or sets the name of the hybrid worker group the watcher will run on. + :vartype script_run_on: str :ivar status: Gets the current status of the watcher. :vartype status: str :ivar creation_time: Gets or sets the creation time. @@ -6496,8 +8907,8 @@ class Watcher(Resource): :vartype last_modified_time: ~datetime.datetime :ivar last_modified_by: Details of the user who last modified the watcher. :vartype last_modified_by: str - :param description: Gets or sets the description. - :type description: str + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -6541,6 +8952,27 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword etag: Gets or sets the etag of the resource. + :paramtype etag: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is + invoked. + :paramtype execution_frequency_in_seconds: long + :keyword script_name: Gets or sets the name of the script the watcher is attached to, i.e. the + name of an existing runbook. + :paramtype script_name: str + :keyword script_parameters: Gets or sets the parameters of the script. + :paramtype script_parameters: dict[str, str] + :keyword script_run_on: Gets or sets the name of the hybrid worker group the watcher will run + on. + :paramtype script_run_on: str + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Watcher, self).__init__(**kwargs) self.etag = etag self.tags = tags @@ -6559,10 +8991,10 @@ def __init__( class WatcherListResult(msrest.serialization.Model): """The response model for the list watcher operation. - :param value: Gets or sets a list of watchers. - :type value: list[~azure.mgmt.automation.models.Watcher] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of watchers. + :vartype value: list[~azure.mgmt.automation.models.Watcher] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -6573,10 +9005,16 @@ class WatcherListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Watcher"]] = None, + value: Optional[List["_models.Watcher"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of watchers. + :paramtype value: list[~azure.mgmt.automation.models.Watcher] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(WatcherListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6585,11 +9023,11 @@ def __init__( class WatcherUpdateParameters(msrest.serialization.Model): """WatcherUpdateParameters. - :param name: Gets or sets the name of the resource. - :type name: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is + :ivar name: Gets or sets the name of the resource. + :vartype name: str + :ivar execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is invoked. - :type execution_frequency_in_seconds: long + :vartype execution_frequency_in_seconds: long """ _attribute_map = { @@ -6604,12 +9042,19 @@ def __init__( execution_frequency_in_seconds: Optional[int] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the resource. + :paramtype name: str + :keyword execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is + invoked. + :paramtype execution_frequency_in_seconds: long + """ super(WatcherUpdateParameters, self).__init__(**kwargs) self.name = name self.execution_frequency_in_seconds = execution_frequency_in_seconds -class Webhook(Resource): +class Webhook(ProxyResource): """Definition of the webhook type. Variables are only populated by the server, and will be ignored when sending a request. @@ -6620,29 +9065,29 @@ class Webhook(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param is_enabled: Gets or sets the value of the enabled flag of the webhook. - :type is_enabled: bool - :param uri: Gets or sets the webhook uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param last_invoked_time: Gets or sets the last invoked time. - :type last_invoked_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job that is created when the webhook - calls the runbook it is associated with. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook the webhook is associated with. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param last_modified_by: Details of the user who last modified the Webhook. - :type last_modified_by: str - :param description: Gets or sets the description. - :type description: str + :ivar is_enabled: Gets or sets the value of the enabled flag of the webhook. + :vartype is_enabled: bool + :ivar uri: Gets or sets the webhook uri. + :vartype uri: str + :ivar expiry_time: Gets or sets the expiry time. + :vartype expiry_time: ~datetime.datetime + :ivar last_invoked_time: Gets or sets the last invoked time. + :vartype last_invoked_time: ~datetime.datetime + :ivar parameters: Gets or sets the parameters of the job that is created when the webhook calls + the runbook it is associated with. + :vartype parameters: dict[str, str] + :ivar runbook: Gets or sets the runbook the webhook is associated with. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :vartype run_on: str + :ivar creation_time: Gets or sets the creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time. + :vartype last_modified_time: ~datetime.datetime + :ivar last_modified_by: Details of the user who last modified the Webhook. + :vartype last_modified_by: str + :ivar description: Gets or sets the description. + :vartype description: str """ _validation = { @@ -6676,7 +9121,7 @@ def __init__( expiry_time: Optional[datetime.datetime] = None, last_invoked_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, str]] = None, - runbook: Optional["RunbookAssociationProperty"] = None, + runbook: Optional["_models.RunbookAssociationProperty"] = None, run_on: Optional[str] = None, creation_time: Optional[datetime.datetime] = None, last_modified_time: Optional[datetime.datetime] = None, @@ -6684,6 +9129,31 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword is_enabled: Gets or sets the value of the enabled flag of the webhook. + :paramtype is_enabled: bool + :keyword uri: Gets or sets the webhook uri. + :paramtype uri: str + :keyword expiry_time: Gets or sets the expiry time. + :paramtype expiry_time: ~datetime.datetime + :keyword last_invoked_time: Gets or sets the last invoked time. + :paramtype last_invoked_time: ~datetime.datetime + :keyword parameters: Gets or sets the parameters of the job that is created when the webhook + calls the runbook it is associated with. + :paramtype parameters: dict[str, str] + :keyword runbook: Gets or sets the runbook the webhook is associated with. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :paramtype run_on: str + :keyword creation_time: Gets or sets the creation time. + :paramtype creation_time: ~datetime.datetime + :keyword last_modified_time: Gets or sets the last modified time. + :paramtype last_modified_time: ~datetime.datetime + :keyword last_modified_by: Details of the user who last modified the Webhook. + :paramtype last_modified_by: str + :keyword description: Gets or sets the description. + :paramtype description: str + """ super(Webhook, self).__init__(**kwargs) self.is_enabled = is_enabled self.uri = uri @@ -6703,20 +9173,20 @@ class WebhookCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param uri: Gets or sets the uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str + :ivar name: Required. Gets or sets the name of the webhook. + :vartype name: str + :ivar is_enabled: Gets or sets the value of the enabled flag of webhook. + :vartype is_enabled: bool + :ivar uri: Gets or sets the uri. + :vartype uri: str + :ivar expiry_time: Gets or sets the expiry time. + :vartype expiry_time: ~datetime.datetime + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] + :ivar runbook: Gets or sets the runbook. + :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :ivar run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :vartype run_on: str """ _validation = { @@ -6741,10 +9211,26 @@ def __init__( uri: Optional[str] = None, expiry_time: Optional[datetime.datetime] = None, parameters: Optional[Dict[str, str]] = None, - runbook: Optional["RunbookAssociationProperty"] = None, + runbook: Optional["_models.RunbookAssociationProperty"] = None, run_on: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the name of the webhook. + :paramtype name: str + :keyword is_enabled: Gets or sets the value of the enabled flag of webhook. + :paramtype is_enabled: bool + :keyword uri: Gets or sets the uri. + :paramtype uri: str + :keyword expiry_time: Gets or sets the expiry time. + :paramtype expiry_time: ~datetime.datetime + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + :keyword runbook: Gets or sets the runbook. + :paramtype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty + :keyword run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :paramtype run_on: str + """ super(WebhookCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.is_enabled = is_enabled @@ -6758,10 +9244,10 @@ def __init__( class WebhookListResult(msrest.serialization.Model): """The response model for the list webhook operation. - :param value: Gets or sets a list of webhooks. - :type value: list[~azure.mgmt.automation.models.Webhook] - :param next_link: Gets or sets the next link. - :type next_link: str + :ivar value: Gets or sets a list of webhooks. + :vartype value: list[~azure.mgmt.automation.models.Webhook] + :ivar next_link: Gets or sets the next link. + :vartype next_link: str """ _attribute_map = { @@ -6772,10 +9258,16 @@ class WebhookListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Webhook"]] = None, + value: Optional[List["_models.Webhook"]] = None, next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Gets or sets a list of webhooks. + :paramtype value: list[~azure.mgmt.automation.models.Webhook] + :keyword next_link: Gets or sets the next link. + :paramtype next_link: str + """ super(WebhookListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6784,16 +9276,16 @@ def __init__( class WebhookUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update webhook operation. - :param name: Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param description: Gets or sets the description of the webhook. - :type description: str + :ivar name: Gets or sets the name of the webhook. + :vartype name: str + :ivar is_enabled: Gets or sets the value of the enabled flag of webhook. + :vartype is_enabled: bool + :ivar run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :vartype run_on: str + :ivar parameters: Gets or sets the parameters of the job. + :vartype parameters: dict[str, str] + :ivar description: Gets or sets the description of the webhook. + :vartype description: str """ _attribute_map = { @@ -6814,6 +9306,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the webhook. + :paramtype name: str + :keyword is_enabled: Gets or sets the value of the enabled flag of webhook. + :paramtype is_enabled: bool + :keyword run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. + :paramtype run_on: str + :keyword parameters: Gets or sets the parameters of the job. + :paramtype parameters: dict[str, str] + :keyword description: Gets or sets the description of the webhook. + :paramtype description: str + """ super(WebhookUpdateParameters, self).__init__(**kwargs) self.name = name self.is_enabled = is_enabled @@ -6825,18 +9329,18 @@ def __init__( class WindowsProperties(msrest.serialization.Model): """Windows specific update configuration. - :param included_update_classifications: Update classification included in the software update - configuration. A comma separated string with required values. Possible values include: - "Unclassified", "Critical", "Security", "UpdateRollup", "FeaturePack", "ServicePack", - "Definition", "Tools", "Updates". - :type included_update_classifications: str or + :ivar included_update_classifications: Update classification included in the software update + configuration. A comma separated string with required values. Known values are: "Unclassified", + "Critical", "Security", "UpdateRollup", "FeaturePack", "ServicePack", "Definition", "Tools", + "Updates". + :vartype included_update_classifications: str or ~azure.mgmt.automation.models.WindowsUpdateClasses - :param excluded_kb_numbers: KB numbers excluded from the software update configuration. - :type excluded_kb_numbers: list[str] - :param included_kb_numbers: KB numbers included from the software update configuration. - :type included_kb_numbers: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str + :ivar excluded_kb_numbers: KB numbers excluded from the software update configuration. + :vartype excluded_kb_numbers: list[str] + :ivar included_kb_numbers: KB numbers included from the software update configuration. + :vartype included_kb_numbers: list[str] + :ivar reboot_setting: Reboot setting for the software update configuration. + :vartype reboot_setting: str """ _attribute_map = { @@ -6849,12 +9353,26 @@ class WindowsProperties(msrest.serialization.Model): def __init__( self, *, - included_update_classifications: Optional[Union[str, "WindowsUpdateClasses"]] = None, + included_update_classifications: Optional[Union[str, "_models.WindowsUpdateClasses"]] = None, excluded_kb_numbers: Optional[List[str]] = None, included_kb_numbers: Optional[List[str]] = None, reboot_setting: Optional[str] = None, **kwargs ): + """ + :keyword included_update_classifications: Update classification included in the software update + configuration. A comma separated string with required values. Known values are: "Unclassified", + "Critical", "Security", "UpdateRollup", "FeaturePack", "ServicePack", "Definition", "Tools", + "Updates". + :paramtype included_update_classifications: str or + ~azure.mgmt.automation.models.WindowsUpdateClasses + :keyword excluded_kb_numbers: KB numbers excluded from the software update configuration. + :paramtype excluded_kb_numbers: list[str] + :keyword included_kb_numbers: KB numbers included from the software update configuration. + :paramtype included_kb_numbers: list[str] + :keyword reboot_setting: Reboot setting for the software update configuration. + :paramtype reboot_setting: str + """ super(WindowsProperties, self).__init__(**kwargs) self.included_update_classifications = included_update_classifications self.excluded_kb_numbers = excluded_kb_numbers diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py index d7371312a9c8..e8ed3f355edf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py @@ -6,25 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._runbook_draft_operations import RunbookDraftOperations -from ._runbook_operations import RunbookOperations -from ._test_job_streams_operations import TestJobStreamsOperations -from ._test_job_operations import TestJobOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._python2_package_operations import Python2PackageOperations from ._agent_registration_information_operations import AgentRegistrationInformationOperations from ._dsc_node_operations import DscNodeOperations from ._node_reports_operations import NodeReportsOperations +from ._dsc_node_configuration_operations import DscNodeConfigurationOperations from ._dsc_compilation_job_operations import DscCompilationJobOperations from ._dsc_compilation_job_stream_operations import DscCompilationJobStreamOperations -from ._dsc_node_configuration_operations import DscNodeConfigurationOperations from ._node_count_information_operations import NodeCountInformationOperations -from ._software_update_configuration_runs_operations import SoftwareUpdateConfigurationRunsOperations -from ._software_update_configuration_machine_runs_operations import SoftwareUpdateConfigurationMachineRunsOperations from ._source_control_operations import SourceControlOperations from ._source_control_sync_job_operations import SourceControlSyncJobOperations from ._source_control_sync_job_streams_operations import SourceControlSyncJobStreamsOperations -from ._job_operations import JobOperations -from ._job_stream_operations import JobStreamOperations from ._automation_account_operations import AutomationAccountOperations from ._statistics_operations import StatisticsOperations from ._usages_operations import UsagesOperations @@ -33,8 +27,6 @@ from ._connection_operations import ConnectionOperations from ._connection_type_operations import ConnectionTypeOperations from ._credential_operations import CredentialOperations -from ._dsc_configuration_operations import DscConfigurationOperations -from ._software_update_configurations_operations import SoftwareUpdateConfigurationsOperations from ._hybrid_runbook_worker_group_operations import HybridRunbookWorkerGroupOperations from ._job_schedule_operations import JobScheduleOperations from ._linked_workspace_operations import LinkedWorkspaceOperations @@ -42,32 +34,41 @@ from ._module_operations import ModuleOperations from ._object_data_types_operations import ObjectDataTypesOperations from ._fields_operations import FieldsOperations -from ._operations import Operations from ._schedule_operations import ScheduleOperations from ._variable_operations import VariableOperations from ._watcher_operations import WatcherOperations +from ._dsc_configuration_operations import DscConfigurationOperations +from ._job_operations import JobOperations +from ._job_stream_operations import JobStreamOperations +from ._operations import Operations +from ._automation_client_operations import AutomationClientOperationsMixin +from ._software_update_configurations_operations import SoftwareUpdateConfigurationsOperations +from ._software_update_configuration_runs_operations import SoftwareUpdateConfigurationRunsOperations +from ._software_update_configuration_machine_runs_operations import SoftwareUpdateConfigurationMachineRunsOperations +from ._runbook_draft_operations import RunbookDraftOperations +from ._runbook_operations import RunbookOperations +from ._test_job_streams_operations import TestJobStreamsOperations +from ._test_job_operations import TestJobOperations from ._webhook_operations import WebhookOperations +from ._hybrid_runbook_workers_operations import HybridRunbookWorkersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'RunbookDraftOperations', - 'RunbookOperations', - 'TestJobStreamsOperations', - 'TestJobOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', 'Python2PackageOperations', 'AgentRegistrationInformationOperations', 'DscNodeOperations', 'NodeReportsOperations', + 'DscNodeConfigurationOperations', 'DscCompilationJobOperations', 'DscCompilationJobStreamOperations', - 'DscNodeConfigurationOperations', 'NodeCountInformationOperations', - 'SoftwareUpdateConfigurationRunsOperations', - 'SoftwareUpdateConfigurationMachineRunsOperations', 'SourceControlOperations', 'SourceControlSyncJobOperations', 'SourceControlSyncJobStreamsOperations', - 'JobOperations', - 'JobStreamOperations', 'AutomationAccountOperations', 'StatisticsOperations', 'UsagesOperations', @@ -76,8 +77,6 @@ 'ConnectionOperations', 'ConnectionTypeOperations', 'CredentialOperations', - 'DscConfigurationOperations', - 'SoftwareUpdateConfigurationsOperations', 'HybridRunbookWorkerGroupOperations', 'JobScheduleOperations', 'LinkedWorkspaceOperations', @@ -85,9 +84,23 @@ 'ModuleOperations', 'ObjectDataTypesOperations', 'FieldsOperations', - 'Operations', 'ScheduleOperations', 'VariableOperations', 'WatcherOperations', + 'DscConfigurationOperations', + 'JobOperations', + 'JobStreamOperations', + 'Operations', + 'AutomationClientOperationsMixin', + 'SoftwareUpdateConfigurationsOperations', + 'SoftwareUpdateConfigurationRunsOperations', + 'SoftwareUpdateConfigurationMachineRunsOperations', + 'RunbookDraftOperations', + 'RunbookOperations', + 'TestJobStreamsOperations', + 'TestJobOperations', 'WebhookOperations', + 'HybridRunbookWorkersOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py index b0fade70343f..98601aaa74aa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + activity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "activityName": _SERIALIZER.url("activity_name", activity_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_module_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class ActivityOperations(object): - """ActivityOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActivityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`activity` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - activity_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Activity" + resource_group_name: str, + automation_account_name: str, + module_name: str, + activity_name: str, + **kwargs: Any + ) -> _models.Activity: """Retrieve the activity in the module identified by module name and activity name. :param resource_group_name: Name of an Azure Resource group. @@ -64,45 +145,50 @@ def get( :type module_name: str :param activity_name: The name of activity. :type activity_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Activity"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'activityName': self._serialize.url("activity_name", activity_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Activity] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + activity_name=activity_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Activity', pipeline_response) @@ -111,16 +197,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}"} # type: ignore + + + @distributed_trace def list_by_module( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActivityListResult"] + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> Iterable[_models.ActivityListResult]: """Retrieve a list of activities in the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -129,47 +217,59 @@ def list_by_module( :type automation_account_name: str :param module_name: The name of module. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActivityListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_module.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_module.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ActivityListResult', pipeline_response) + deserialized = self._deserialize("ActivityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +278,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_module.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities'} # type: ignore + list_by_module.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py index 8424b6318383..dedc1e74ee1c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,182 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_regenerate_key_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + *, + json: Optional[_models.AgentRegistrationRegenerateKeyParameter] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class AgentRegistrationInformationOperations(object): - """AgentRegistrationInformationOperations operations. + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AgentRegistrationInformationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`agent_registration_information` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AgentRegistration" + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> _models.AgentRegistration: """Retrieve the automation agent registration information. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentRegistration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AgentRegistration] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AgentRegistration', pipeline_response) @@ -102,16 +190,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation"} # type: ignore + + + @distributed_trace def regenerate_key( self, - resource_group_name, # type: str - automation_account_name, # type: str - parameters, # type: "_models.AgentRegistrationRegenerateKeyParameter" - **kwargs # type: Any - ): - # type: (...) -> "_models.AgentRegistration" + resource_group_name: str, + automation_account_name: str, + parameters: _models.AgentRegistrationRegenerateKeyParameter, + **kwargs: Any + ) -> _models.AgentRegistration: """Regenerate a primary or secondary agent registration key. :param resource_group_name: Name of an Azure Resource group. @@ -120,48 +210,52 @@ def regenerate_key( :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AgentRegistration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AgentRegistration] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') + + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AgentRegistration', pipeline_response) @@ -170,4 +264,6 @@ def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey'} # type: ignore + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py index e1f427427c47..777057c256cb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,286 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + json: Optional[_models.AutomationAccountUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + json: Optional[_models.AutomationAccountCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class AutomationAccountOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AutomationAccountOperations(object): - """AutomationAccountOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`automation_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - parameters, # type: "_models.AutomationAccountUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutomationAccount" + resource_group_name: str, + automation_account_name: str, + parameters: _models.AutomationAccountUpdateParameters, + **kwargs: Any + ) -> _models.AutomationAccount: """Update an automation account. :param resource_group_name: Name of an Azure Resource group. @@ -61,48 +294,52 @@ def update( :type automation_account_name: str :param parameters: Parameters supplied to the update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + _json = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -111,16 +348,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - parameters, # type: "_models.AutomationAccountCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutomationAccount" + resource_group_name: str, + automation_account_name: str, + parameters: _models.AutomationAccountCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.AutomationAccount: """Create or update automation account. :param resource_group_name: Name of an Azure Resource group. @@ -129,48 +368,52 @@ def create_or_update( :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + _json = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -183,115 +426,128 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> None: """Delete an automation account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutomationAccount" + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> _models.AutomationAccount: """Get information about an Automation Account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccount] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -300,57 +556,70 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationAccountListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.AutomationAccountListResult]: """Retrieve a list of accounts within a given resource group. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AutomationAccountListResult', pipeline_response) + deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,68 +628,83 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts"} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationAccountListResult"] + **kwargs: Any + ) -> Iterable[_models.AutomationAccountListResult]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AutomationAccountListResult', pipeline_response) + deserialized = self._deserialize("AutomationAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -429,17 +713,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py new file mode 100644 index 000000000000..08c2b9f3c051 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py @@ -0,0 +1,147 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_convert_graph_runbook_content_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + json: Optional[_models.GraphicalRunbookContent] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class AutomationClientOperationsMixin(MixinABC): + + @distributed_trace + def convert_graph_runbook_content( + self, + resource_group_name: str, + automation_account_name: str, + parameters: _models.GraphicalRunbookContent, + **kwargs: Any + ) -> _models.GraphicalRunbookContent: + """Post operation to serialize or deserialize GraphRunbookContent. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param parameters: Input data describing the graphical runbook. + :type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GraphicalRunbookContent, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphicalRunbookContent] + + _json = self._serialize.body(parameters, 'GraphicalRunbookContent') + + request = build_convert_graph_runbook_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.convert_graph_runbook_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GraphicalRunbookContent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + convert_graph_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py index 9387b3b3e469..198c3340d81c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + *, + json: Optional[_models.CertificateCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + *, + json: Optional[_models.CertificateUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class CertificateOperations(object): - """CertificateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: """Delete the certificate. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +271,65 @@ def delete( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + **kwargs: Any + ) -> _models.Certificate: """Retrieve the certificate identified by certificate name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +338,49 @@ def get( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Certificate', pipeline_response) @@ -168,17 +389,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - parameters, # type: "_models.CertificateCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + parameters: _models.CertificateCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Certificate: """Create a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +412,53 @@ def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +471,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - parameters, # type: "_models.CertificateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + parameters: _models.CertificateUpdateParameters, + **kwargs: Any + ) -> _models.Certificate: """Update a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -265,49 +494,53 @@ def update( :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Certificate', pipeline_response) @@ -316,61 +549,75 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CertificateListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.CertificateListResult]: """Retrieve a list of certificates. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateListResult or the result of cls(response) + :return: An iterator like instance of either CertificateListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.CertificateListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CertificateListResult', pipeline_response) + deserialized = self._deserialize("CertificateListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,17 +626,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py index cb6d8fd83ae7..d8936531f423 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + *, + json: Optional[_models.ConnectionCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + *, + json: Optional[_models.ConnectionUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ConnectionOperations(object): - """ConnectionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`connection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + connection_name: str, + **kwargs: Any + ) -> None: """Delete the connection. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +271,65 @@ def delete( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + **kwargs: Any + ) -> _models.Connection: """Retrieve the connection identified by connection name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +338,49 @@ def get( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Connection', pipeline_response) @@ -168,17 +389,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - parameters, # type: "_models.ConnectionCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + parameters: _models.ConnectionCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Connection: """Create or update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +412,53 @@ def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + _json = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +471,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - parameters, # type: "_models.ConnectionUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + parameters: _models.ConnectionUpdateParameters, + **kwargs: Any + ) -> _models.Connection: """Update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -265,49 +494,53 @@ def update( :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Connection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionName': self._serialize.url("connection_name", connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Connection] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Connection', pipeline_response) @@ -316,61 +549,75 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConnectionListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.ConnectionListResult]: """Retrieve a list of connections. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionListResult or the result of cls(response) + :return: An iterator like instance of either ConnectionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConnectionListResult', pipeline_response) + deserialized = self._deserialize("ConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,17 +626,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py index 51e8e25f5b37..186dafb7e07f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,216 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + subscription_id: str, + *, + json: Optional[_models.ConnectionTypeCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConnectionTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ConnectionTypeOperations(object): - """ConnectionTypeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`connection_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + **kwargs: Any + ) -> None: """Delete the connection type. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +224,65 @@ def delete( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectionType" + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + **kwargs: Any + ) -> _models.ConnectionType: """Retrieve the connection type identified by connection type name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +291,49 @@ def get( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionType"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionType] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConnectionType', pipeline_response) @@ -168,17 +342,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - parameters, # type: "_models.ConnectionTypeCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectionType" + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + parameters: _models.ConnectionTypeCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.ConnectionType: """Create a connection type. :param resource_group_name: Name of an Azure Resource group. @@ -190,49 +366,53 @@ def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionType"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'connectionTypeName': self._serialize.url("connection_type_name", connection_type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionType] + + _json = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_type_name=connection_type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConnectionType', pipeline_response) @@ -241,61 +421,75 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConnectionTypeListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.ConnectionTypeListResult]: """Retrieve a list of connection types. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionTypeListResult or the result of cls(response) + :return: An iterator like instance of either ConnectionTypeListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionTypeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionTypeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConnectionTypeListResult', pipeline_response) + deserialized = self._deserialize("ConnectionTypeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -304,17 +498,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py index 46682979714b..f62ddd61f2fe 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + *, + json: Optional[_models.CredentialCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + *, + json: Optional[_models.CredentialUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CredentialOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class CredentialOperations(object): - """CredentialOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`credential` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + credential_name: str, + **kwargs: Any + ) -> None: """Delete the credential. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +271,65 @@ def delete( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + **kwargs: Any + ) -> _models.Credential: """Retrieve the credential identified by credential name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +338,49 @@ def get( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Credential', pipeline_response) @@ -168,17 +389,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - parameters, # type: "_models.CredentialCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + parameters: _models.CredentialCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Credential: """Create a credential. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +412,53 @@ def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + _json = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +471,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - parameters, # type: "_models.CredentialUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + parameters: _models.CredentialUpdateParameters, + **kwargs: Any + ) -> _models.Credential: """Update a credential. :param resource_group_name: Name of an Azure Resource group. @@ -265,49 +494,53 @@ def update( :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Credential"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'credentialName': self._serialize.url("credential_name", credential_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Credential] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Credential', pipeline_response) @@ -316,61 +549,75 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CredentialListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.CredentialListResult]: """Retrieve a list of credentials. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CredentialListResult or the result of cls(response) + :return: An iterator like instance of either CredentialListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.CredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CredentialListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CredentialListResult', pipeline_response) + deserialized = self._deserialize("CredentialListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,7 +626,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,7 +639,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py index 753e49c664b7..c4317fb77256 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + subscription_id: str, + *, + json: Optional[_models.DscCompilationJobCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "compilationJobName": _SERIALIZER.url("compilation_job_name", compilation_job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "compilationJobName": _SERIALIZER.url("compilation_job_name", compilation_job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_stream_request( + resource_group_name: str, + automation_account_name: str, + job_id: str, + job_stream_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DscCompilationJobOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DscCompilationJobOperations(object): - """DscCompilationJobOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`dsc_compilation_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, - resource_group_name, # type: str - automation_account_name, # type: str - compilation_job_name, # type: str - parameters, # type: "_models.DscCompilationJobCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DscCompilationJob" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + parameters: _models.DscCompilationJobCreateParameters, + **kwargs: Any + ) -> _models.DscCompilationJob: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] + + _json = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + compilation_job_name=compilation_job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('DscCompilationJob', pipeline_response) @@ -102,17 +270,19 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - automation_account_name, # type: str - compilation_job_name, # type: str - parameters, # type: "_models.DscCompilationJobCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DscCompilationJob"] + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + parameters: _models.DscCompilationJobCreateParameters, + **kwargs: Any + ) -> LROPoller[_models.DscCompilationJob]: """Creates the Dsc compilation job of the configuration. :param resource_group_name: Name of an Azure Resource group. @@ -123,52 +293,64 @@ def begin_create( :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DscCompilationJob or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DscCompilationJob or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscCompilationJob] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DscCompilationJob', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -177,18 +359,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - compilation_job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscCompilationJob" + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + **kwargs: Any + ) -> _models.DscCompilationJob: """Retrieve the Dsc configuration compilation job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -197,44 +379,49 @@ def get( :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. :type compilation_job_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'compilationJobName': self._serialize.url("compilation_job_name", compilation_job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJob] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + compilation_job_name=compilation_job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscCompilationJob', pipeline_response) @@ -243,66 +430,80 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscCompilationJobListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DscCompilationJobListResult]: """Retrieve a list of dsc compilation jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscCompilationJobListResult or the result of cls(response) + :return: An iterator like instance of either DscCompilationJobListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJobListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscCompilationJobListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DscCompilationJobListResult', pipeline_response) + deserialized = self._deserialize("DscCompilationJobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -311,30 +512,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs"} # type: ignore + @distributed_trace def get_stream( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_id, # type: str - job_stream_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStream" + resource_group_name: str, + automation_account_name: str, + job_id: str, + job_stream_id: str, + **kwargs: Any + ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. :param resource_group_name: Name of an Azure Resource group. @@ -345,45 +551,50 @@ def get_stream( :type job_id: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_stream.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] + + + request = build_get_stream_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_id=job_id, + job_stream_id=job_stream_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stream.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -392,4 +603,6 @@ def get_stream( return cls(pipeline_response, deserialized, {}) return deserialized - get_stream.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}'} # type: ignore + + get_stream.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py index 1726272bfbda..cc82aafc6349 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,92 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_job_request( + resource_group_name: str, + automation_account_name: str, + job_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DscCompilationJobStreamOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DscCompilationJobStreamOperations(object): - """DscCompilationJobStreamOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`dsc_compilation_job_stream` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStreamListResult" + resource_group_name: str, + automation_account_name: str, + job_id: str, + **kwargs: Any + ) -> _models.JobStreamListResult: """Retrieve all the job streams for the compilation Job. :param resource_group_name: Name of an Azure Resource group. @@ -60,44 +100,49 @@ def list_by_job( :type automation_account_name: str :param job_id: The job id. :type job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStreamListResult', pipeline_response) @@ -106,4 +151,6 @@ def list_by_job( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams'} # type: ignore + + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py index 48af11730a06..6cd7d107baec 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,315 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + *, + json: Optional[_models.DscConfigurationCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + *, + json: Optional[_models.DscConfigurationUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_content_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "text/powershell") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + _params['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DscConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DscConfigurationOperations(object): - """DscConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`dsc_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def delete( + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> None: """Delete the dsc configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +323,65 @@ def delete( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> _models.DscConfiguration: """Retrieve the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +390,49 @@ def get( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscConfiguration', pipeline_response) @@ -168,17 +441,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - parameters, # type: Union[str, "_models.DscConfigurationCreateOrUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + parameters: Union[str, _models.DscConfigurationCreateOrUpdateParameters], + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -189,60 +466,67 @@ def create_or_update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Known values are: "text/plain; + charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/plain; charset=utf-8") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['text/plain']: - body_content = self._serialize.body(parameters, 'str') - body_content_kwargs['content'] = body_content - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - body_content = self._serialize.body(parameters, 'DscConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + _json = None + _content = None + content_type = content_type or "" + if content_type.split(";")[0] in ['application/json']: + _json = parameters + elif content_type.split(";")[0] in ['text/plain']: + _content = parameters else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['text/plain; charset=utf-8', 'application/json']".format(header_parameters['Content-Type']) + "['text/plain; charset=utf-8', 'application/json']".format(content_type) ) - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -255,17 +539,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - parameters=None, # type: Optional[Union[str, "_models.DscConfigurationUpdateParameters"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + parameters: Optional[Union[str, _models.DscConfigurationUpdateParameters]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> _models.DscConfiguration: """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -274,65 +562,69 @@ def update( :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. :type configuration_name: str - :param parameters: The create or update parameters for configuration. + :param parameters: The create or update parameters for configuration. Default value is None. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Known values are: "text/plain; + charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/plain; charset=utf-8") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['text/plain']: - body_content = self._serialize.body(parameters, 'str') - body_content_kwargs['content'] = body_content - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - if parameters is not None: - body_content = self._serialize.body(parameters, 'DscConfigurationUpdateParameters') - else: - body_content = None - body_content_kwargs['content'] = body_content + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfiguration] + + _json = None + _content = None + content_type = content_type or "" + if content_type.split(";")[0] in ['application/json']: + _json = parameters + elif content_type.split(";")[0] in ['text/plain']: + _content = parameters else: raise ValueError( "The content_type '{}' is not one of the allowed values: " - "['text/plain; charset=utf-8', 'application/json']".format(header_parameters['Content-Type']) + "['text/plain; charset=utf-8', 'application/json']".format(content_type) ) - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscConfiguration', pipeline_response) @@ -341,16 +633,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> str: """Retrieve the configuration script identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -359,39 +653,44 @@ def get_content( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,81 +703,95 @@ def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscConfigurationListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DscConfigurationListResult]: """Retrieve a list of configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscConfigurationListResult or the result of cls(response) + :return: An iterator like instance of either DscConfigurationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscConfigurationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DscConfigurationListResult', pipeline_response) + deserialized = self._deserialize("DscConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -487,17 +800,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py index 45317cc8dfce..45a99bb44475 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,56 +6,231 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + subscription_id: str, + *, + json: Optional[_models.DscNodeConfigurationCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + _params['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DscNodeConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DscNodeConfigurationOperations(object): - """DscNodeConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`dsc_node_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def delete( + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any + ) -> None: """Delete the Dsc node configurations by node configuration. :param resource_group_name: Name of an Azure Resource group. @@ -63,59 +239,65 @@ def delete( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNodeConfiguration" + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any + ) -> _models.DscNodeConfiguration: """Retrieve the Dsc node configurations by node configuration. :param resource_group_name: Name of an Azure Resource group. @@ -124,44 +306,49 @@ def get( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNodeConfiguration', pipeline_response) @@ -170,56 +357,57 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - parameters, # type: "_models.DscNodeConfigurationCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DscNodeConfiguration"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DscNodeConfiguration"]] + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + parameters: _models.DscNodeConfigurationCreateOrUpdateParameters, + **kwargs: Any + ) -> Optional[_models.DscNodeConfiguration]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DscNodeConfiguration]] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 201: @@ -229,17 +417,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - parameters, # type: "_models.DscNodeConfigurationCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DscNodeConfiguration"] + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + parameters: _models.DscNodeConfigurationCreateOrUpdateParameters, + **kwargs: Any + ) -> LROPoller[_models.DscNodeConfiguration]: """Create the node configuration identified by node configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -250,52 +440,64 @@ def begin_create_or_update( :type node_configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DscNodeConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfiguration] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('DscNodeConfiguration', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeConfigurationName': self._serialize.url("node_configuration_name", node_configuration_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -304,83 +506,96 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscNodeConfigurationListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DscNodeConfigurationListResult]: """Retrieve a list of dsc node configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] + :return: An iterator like instance of either DscNodeConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeConfigurationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeConfigurationListResult', pipeline_response) + deserialized = self._deserialize("DscNodeConfigurationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -389,17 +604,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py index 49866da11b67..85afb5bd8ea5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + *, + json: Optional[_models.DscNodeUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + _params['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class DscNodeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DscNodeOperations(object): - """DscNodeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`dsc_node` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + node_id: str, + **kwargs: Any + ) -> None: """Delete the dsc node identified by node id. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +237,65 @@ def delete( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNode" + resource_group_name: str, + automation_account_name: str, + node_id: str, + **kwargs: Any + ) -> _models.DscNode: """Retrieve the dsc node identified by node id. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +304,49 @@ def get( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNode"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNode] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -168,17 +355,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - dsc_node_update_parameters, # type: "_models.DscNodeUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNode" + resource_group_name: str, + automation_account_name: str, + node_id: str, + dsc_node_update_parameters: _models.DscNodeUpdateParameters, + **kwargs: Any + ) -> _models.DscNode: """Update the dsc node. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +378,53 @@ def update( :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNode"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNode] + + _json = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -240,81 +433,94 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscNodeListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DscNodeListResult]: """Retrieve a list of dsc nodes. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeListResult', pipeline_response) + deserialized = self._deserialize("DscNodeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -323,17 +529,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py index f1a689f580b7..c8d773cbb0c4 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_type_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class FieldsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class FieldsOperations(object): - """FieldsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`fields` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_type( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TypeFieldListResult"] + resource_group_name: str, + automation_account_name: str, + module_name: str, + type_name: str, + **kwargs: Any + ) -> Iterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -64,48 +106,61 @@ def list_by_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,17 +169,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py index 63abed20de87..3487c7d855df 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + *, + json: Optional[_models.HybridRunbookWorkerGroupCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + *, + json: Optional[_models.HybridRunbookWorkerGroupCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class HybridRunbookWorkerGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class HybridRunbookWorkerGroupOperations(object): - """HybridRunbookWorkerGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`hybrid_runbook_worker_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def delete( + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - hybrid_runbook_worker_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + **kwargs: Any + ) -> None: """Delete a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +275,65 @@ def delete( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - hybrid_runbook_worker_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridRunbookWorkerGroup" + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: """Retrieve a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +342,129 @@ def get( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace + def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_group_creation_parameters: _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: + """Create a hybrid runbook worker group. - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_group_creation_parameters: The create or update parameters for + hybrid runbook worker group. + :type hybrid_runbook_worker_group_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorkerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + _json = self._serialize.body(hybrid_runbook_worker_group_creation_parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -168,17 +473,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - hybrid_runbook_worker_group_name, # type: str - parameters, # type: "_models.HybridRunbookWorkerGroupUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridRunbookWorkerGroup" + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + parameters: _models.HybridRunbookWorkerGroupCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorkerGroup: """Update a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -188,50 +495,55 @@ def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str :param parameters: The hybrid runbook worker group. - :type parameters: ~azure.mgmt.automation.models.HybridRunbookWorkerGroupUpdateParameters + :type parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'hybridRunbookWorkerGroupName': self._serialize.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridRunbookWorkerGroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroup] + + _json = self._serialize.body(parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -240,66 +552,81 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HybridRunbookWorkerGroupsListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.HybridRunbookWorkerGroupsListResult]: """Retrieve a list of hybrid runbook worker groups. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] + :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroupsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkerGroupsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HybridRunbookWorkerGroupsListResult', pipeline_response) + deserialized = self._deserialize("HybridRunbookWorkerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -308,17 +635,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py new file mode 100644 index 000000000000..5bf5d7bb5278 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,683 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + subscription_id: str, + *, + json: Optional[_models.HybridRunbookWorkerCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_move_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + subscription_id: str, + *, + json: Optional[_models.HybridRunbookWorkerMoveParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_hybrid_runbook_worker_group_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class HybridRunbookWorkersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`hybrid_runbook_workers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> None: + """Delete a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> _models.HybridRunbookWorker: + """Retrieve a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorker] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_creation_parameters: _models.HybridRunbookWorkerCreateParameters, + **kwargs: Any + ) -> _models.HybridRunbookWorker: + """Create a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid + runbook worker. + :type hybrid_runbook_worker_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorker] + + _json = self._serialize.body(hybrid_runbook_worker_creation_parameters, 'HybridRunbookWorkerCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def move( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_move_parameters: _models.HybridRunbookWorkerMoveParameters, + **kwargs: Any + ) -> None: + """Move a hybrid worker to a different group. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. + :type hybrid_runbook_worker_move_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(hybrid_runbook_worker_move_parameters, 'HybridRunbookWorkerMoveParameters') + + request = build_move_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + move.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move"} # type: ignore + + + @distributed_trace + def list_by_hybrid_runbook_worker_group( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.HybridRunbookWorkersListResult]: + """Retrieve a list of hybrid runbook workers. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridRunbookWorkersListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkersListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridRunbookWorkersListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("HybridRunbookWorkersListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_hybrid_runbook_worker_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py index 2afce74497f4..c1adbf23cf56 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,407 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_output_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "text/plain") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_runbook_content_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "text/powershell") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_suspend_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_stop_request( + resource_group_name: str, + automation_account_name: str, + job_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + json: Optional[_models.JobCreateParameters] = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_resume_request( + resource_group_name: str, + automation_account_name: str, + job_name: str, + subscription_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JobOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class JobOperations(object): - """JobOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get_output( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> str: """Retrieve the job output identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -62,43 +415,47 @@ def get_output( :type automation_account_name: str :param job_name: The name of the job to be created. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/plain" - - # Construct URL - url = self.get_output.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,17 +468,19 @@ def get_output( return cls(pipeline_response, deserialized, {}) return deserialized - get_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output'} # type: ignore + get_output.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output"} # type: ignore + + + @distributed_trace def get_runbook_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> str: """Retrieve the runbook content of the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -130,43 +489,47 @@ def get_runbook_content( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_runbook_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_runbook_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,17 +542,19 @@ def get_runbook_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_runbook_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent'} # type: ignore - def suspend( + get_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent"} # type: ignore + + + @distributed_trace + def suspend( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Suspend the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -198,64 +563,69 @@ def suspend( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.suspend.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend"} # type: ignore + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Stop the job identified by jobName. :param resource_group_name: Name of an Azure Resource group. @@ -264,64 +634,69 @@ def stop( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.Job: """Retrieve the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -330,48 +705,52 @@ def get( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -380,18 +759,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - parameters, # type: "_models.JobCreateParameters" - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + automation_account_name: str, + job_name: str, + parameters: _models.JobCreateParameters, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.Job: """Create a job of the runbook. :param resource_group_name: Name of an Azure Resource group. @@ -402,53 +783,56 @@ def create( :type job_name: str :param parameters: The parameters supplied to the create job operation. :type parameters: ~azure.mgmt.automation.models.JobCreateParameters - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Job] + + _json = self._serialize.body(parameters, 'JobCreateParameters') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -457,71 +841,84 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobListResultV2"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.JobListResultV2]: """Retrieve a list of jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobListResultV2 or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobListResultV2] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobListResultV2"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobListResultV2] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobListResultV2', pipeline_response) + deserialized = self._deserialize("JobListResultV2", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -530,30 +927,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs"} # type: ignore - def resume( + @distributed_trace + def resume( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Resume the job identified by jobName. :param resource_group_name: Name of an Azure Resource group. @@ -562,51 +964,56 @@ def resume( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.resume.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_resume_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.resume.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py index d01e390ea63d..37d503573f7b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,220 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + subscription_id: str, + *, + json: Optional[_models.JobScheduleCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class JobScheduleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class JobScheduleOperations(object): - """JobScheduleOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`job_schedule` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + **kwargs: Any + ) -> None: """Delete the job schedule identified by job schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +228,65 @@ def delete( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobSchedule" + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + **kwargs: Any + ) -> _models.JobSchedule: """Retrieve the job schedule identified by job schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +295,49 @@ def get( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobSchedule] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -168,17 +346,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - parameters, # type: "_models.JobScheduleCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobSchedule" + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + parameters: _models.JobScheduleCreateParameters, + **kwargs: Any + ) -> _models.JobSchedule: """Create a job schedule. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +369,53 @@ def create( :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobSchedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobScheduleId': self._serialize.url("job_schedule_id", job_schedule_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobScheduleCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobSchedule] + + _json = self._serialize.body(parameters, 'JobScheduleCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_schedule_id=job_schedule_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -240,66 +424,80 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobScheduleListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.JobScheduleListResult]: """Retrieve a list of job schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobScheduleListResult or the result of cls(response) + :return: An iterator like instance of either JobScheduleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobScheduleListResult', pipeline_response) + deserialized = self._deserialize("JobScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -308,17 +506,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py index 4db34971e8ba..2772dc92ea4b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,56 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + job_stream_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_job_request( + resource_group_name: str, + automation_account_name: str, + job_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class JobStreamOperations(object): - """JobStreamOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobStreamOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`job_stream` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - job_stream_id, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStream" + resource_group_name: str, + automation_account_name: str, + job_name: str, + job_stream_id: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.JobStream: """Retrieve the job stream identified by job stream id. :param resource_group_name: Name of an Azure Resource group. @@ -65,49 +157,53 @@ def get( :type job_name: str :param job_stream_id: The job stream id. :type job_stream_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + job_stream_id=job_stream_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -116,18 +212,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - filter=None, # type: Optional[str] - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStreamListResult"] + resource_group_name: str, + automation_account_name: str, + job_name: str, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.JobStreamListResult]: """Retrieve a list of jobs streams identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -136,55 +234,67 @@ def list_by_job( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobStreamListResult', pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -193,17 +303,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams'} # type: ignore + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py index 247cd84ff235..b60ee45d277b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,137 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class KeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class KeysOperations(object): - """KeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.KeyListResult" + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> _models.KeyListResult: """Retrieve the automation keys for an account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.KeyListResult] + + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('KeyListResult', pipeline_response) @@ -102,4 +145,6 @@ def list_by_automation_account( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys'} # type: ignore + + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py index ba38f637ec4f..6d128e5f0c1f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,137 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class LinkedWorkspaceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class LinkedWorkspaceOperations(object): - """LinkedWorkspaceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`linked_workspace` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LinkedWorkspace" + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> _models.LinkedWorkspace: """Retrieve the linked workspace for the account id. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LinkedWorkspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LinkedWorkspace] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LinkedWorkspace', pipeline_response) @@ -102,4 +145,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py index ccdfd980714a..3389c4f558b8 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + *, + json: Optional[_models.ModuleCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + *, + json: Optional[_models.ModuleUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ModuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ModuleOperations(object): - """ModuleOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`module` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> None: """Delete the module by name. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +271,65 @@ def delete( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> _models.Module: """Retrieve the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +338,49 @@ def get( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -168,17 +389,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - parameters, # type: "_models.ModuleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Create or Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +412,53 @@ def create_or_update( :type module_name: str :param parameters: The create or update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +471,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - parameters, # type: "_models.ModuleUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: _models.ModuleUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -265,49 +494,53 @@ def update( :type module_name: str :param parameters: The update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -316,61 +549,74 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ModuleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.ModuleListResult]: """Retrieve a list of modules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ModuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ModuleListResult', pipeline_response) + deserialized = self._deserialize("ModuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,17 +625,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py index d45cbc7268b9..147472da69dc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,92 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + count_type: Union[str, "_models.CountType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "countType": _SERIALIZER.url("count_type", count_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class NodeCountInformationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class NodeCountInformationOperations(object): - """NodeCountInformationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`node_count_information` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - count_type, # type: Union[str, "_models.CountType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.NodeCounts" + resource_group_name: str, + automation_account_name: str, + count_type: Union[str, "_models.CountType"], + **kwargs: Any + ) -> _models.NodeCounts: """Retrieve counts for Dsc Nodes. :param resource_group_name: Name of an Azure Resource group. @@ -60,44 +100,49 @@ def get( :type automation_account_name: str :param count_type: The type of counts to retrieve. :type count_type: str or ~azure.mgmt.automation.models.CountType + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeCounts"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'countType': self._serialize.url("count_type", count_type, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NodeCounts] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + count_type=count_type, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NodeCounts', pipeline_response) @@ -106,4 +151,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py index 18ae4584c08a..72cde69f0d52 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,180 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_node_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_content_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class NodeReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class NodeReportsOperations(object): - """NodeReportsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`node_reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_node( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscNodeReportListResult"] + resource_group_name: str, + automation_account_name: str, + node_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.DscNodeReportListResult]: """Retrieve the Dsc node report list by node id. :param resource_group_name: Name of an Azure Resource group. @@ -62,51 +188,64 @@ def list_by_node( :type automation_account_name: str :param node_id: The parameters supplied to the list operation. :type node_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeReportListResult or the result of cls(response) + :return: An iterator like instance of either DscNodeReportListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReportListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeReportListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_node.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_node.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DscNodeReportListResult', pipeline_response) + deserialized = self._deserialize("DscNodeReportListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,30 +254,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_node.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports'} # type: ignore + list_by_node.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - report_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNodeReport" + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + **kwargs: Any + ) -> _models.DscNodeReport: """Retrieve the Dsc node report data by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -149,45 +293,50 @@ def get( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReport"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DscNodeReport] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + report_id=report_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNodeReport', pipeline_response) @@ -196,17 +345,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}"} # type: ignore + + + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - report_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> object + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + **kwargs: Any + ) -> Any: """Retrieve the Dsc node reports by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -217,45 +368,50 @@ def get_content( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'reportId': self._serialize.url("report_id", report_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Any] + + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + report_id=report_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('object', pipeline_response) @@ -264,4 +420,6 @@ def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py index 4433d365aee4..eac3b99167c2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_fields_by_module_and_type_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_fields_by_type_request( + resource_group_name: str, + automation_account_name: str, + type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class ObjectDataTypesOperations(object): - """ObjectDataTypesOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectDataTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`object_data_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_fields_by_module_and_type( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TypeFieldListResult"] + resource_group_name: str, + automation_account_name: str, + module_name: str, + type_name: str, + **kwargs: Any + ) -> Iterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -64,48 +145,61 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_module_and_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_module_and_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,29 +208,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_fields_by_module_and_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_module_and_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields"} # type: ignore + @distributed_trace def list_fields_by_type( self, - resource_group_name, # type: str - automation_account_name, # type: str - type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TypeFieldListResult"] + resource_group_name: str, + automation_account_name: str, + type_name: str, + **kwargs: Any + ) -> Iterable[_models.TypeFieldListResult]: """Retrieve a list of fields of a given type across all accessible modules. :param resource_group_name: Name of an Azure Resource group. @@ -145,47 +244,59 @@ def list_fields_by_type( :type automation_account_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TypeFieldListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_type.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TypeFieldListResult', pipeline_response) + deserialized = self._deserialize("TypeFieldListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,17 +305,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_fields_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py index a26716803b06..e979e997de9c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,125 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Automation/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Automation REST API operations. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Automation/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Automation/operations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..a99cecb5b88f --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,652 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_automation_account_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + *, + json: Optional[_models.PrivateEndpointConnection] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_automation_account( + self, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + """List all private endpoint connections on a Automation account. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param parameters: + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..19d9ed93f68c --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py @@ -0,0 +1,177 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_automation_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def automation( + self, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.PrivateLinkResourceListResult]: + """Gets the private link resources that need to be created for Automation account. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateLinkResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.automation.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + automation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py index f28cd6987093..b4da448c5053 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,263 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + *, + json: Optional[_models.PythonPackageCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + *, + json: Optional[_models.PythonPackageUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Python2PackageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class Python2PackageOperations(object): - """Python2PackageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`python2_package` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + package_name: str, + **kwargs: Any + ) -> None: """Delete the python 2 package by name. :param resource_group_name: Name of an Azure Resource group. @@ -61,59 +271,65 @@ def delete( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + **kwargs: Any + ) -> _models.Module: """Retrieve the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -122,44 +338,49 @@ def get( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -168,17 +389,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - parameters, # type: "_models.PythonPackageCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: _models.PythonPackageCreateParameters, + **kwargs: Any + ) -> _models.Module: """Create or Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -189,49 +412,53 @@ def create_or_update( :type package_name: str :param parameters: The create or update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'PythonPackageCreateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +471,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - parameters, # type: "_models.PythonPackageUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: _models.PythonPackageUpdateParameters, + **kwargs: Any + ) -> _models.Module: """Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -265,49 +494,53 @@ def update( :type package_name: str :param parameters: The update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Module"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'packageName': self._serialize.url("package_name", package_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Module] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -316,61 +549,74 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ModuleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.ModuleListResult]: """Retrieve a list of python 2 packages. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ModuleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ModuleListResult', pipeline_response) + deserialized = self._deserialize("ModuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,17 +625,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py index c60a44fca278..3970c28c430b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,217 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_content_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "text/powershell") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_replace_content_request_initial( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + content: Any, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_undo_edit_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class RunbookDraftOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RunbookDraftOperations(object): - """RunbookDraftOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`runbook_draft` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> IO: """Retrieve the content of runbook draft identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -62,120 +225,134 @@ def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + def _replace_content_initial( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - runbook_content, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + runbook_content: str, + **kwargs: Any + ) -> Optional[IO]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "text/powershell") - accept = "application/json" - - # Construct URL - url = self._replace_content_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(runbook_content, 'str') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "text/powershell")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[IO]] + + _content = runbook_content + + request = build_replace_content_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=True, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _replace_content_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore - _replace_content_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + @distributed_trace def begin_replace_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - runbook_content, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + runbook_content: str, + **kwargs: Any + ) -> LROPoller[IO]: """Replaces the runbook draft content. :param resource_group_name: Name of an Azure Resource group. @@ -184,51 +361,65 @@ def begin_replace_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param runbook_content: The runbook draft content. + :param runbook_content: The runbook draft content. :type runbook_content: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IO or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[IO] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "text/powershell")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[IO] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._replace_content_initial( + raw_result = self._replace_content_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + deserialized = response.stream_download(self._client._pipeline) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -237,18 +428,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_replace_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RunbookDraft" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> _models.RunbookDraft: """Retrieve the runbook draft identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -257,44 +448,49 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookDraft"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookDraft] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RunbookDraft', pipeline_response) @@ -303,16 +499,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft"} # type: ignore + + + @distributed_trace def undo_edit( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> _models.RunbookDraftUndoEditResult: """Undo draft edit to last known published state identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -321,47 +519,57 @@ def undo_edit( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: RunbookDraftUndoEditResult, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.undo_edit.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookDraftUndoEditResult] + + + request = build_undo_edit_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.undo_edit.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize('RunbookDraftUndoEditResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized + + undo_edit.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit"} # type: ignore - undo_edit.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit'} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py index 62717cca25ee..c98400d7b8fc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,396 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_publish_request_initial( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_content_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "text/powershell") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + json: Optional[_models.RunbookCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + json: Optional[_models.RunbookUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class RunbookOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RunbookOperations(object): - """RunbookOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`runbook` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + - def _publish_initial( + def _publish_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self._publish_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_publish_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self._publish_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) - _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + _publish_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + - def begin_publish( + @distributed_trace + def begin_publish( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Publish runbook draft. :param resource_group_name: Name of an Azure Resource group. @@ -114,48 +404,58 @@ def begin_publish( :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._publish_initial( + raw_result = self._publish_initial( # type: ignore resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -164,18 +464,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> IO: """Retrieve the content of runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -184,61 +484,68 @@ def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "text/powershell" - - # Construct URL - url = self.get_content.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get_content.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> _models.Runbook: """Retrieve the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -247,44 +554,49 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Runbook', pipeline_response) @@ -293,17 +605,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - parameters, # type: "_models.RunbookCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + parameters: _models.RunbookCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Runbook: """Create the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -315,49 +629,53 @@ def create_or_update( :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + _json = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -370,17 +688,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - parameters, # type: "_models.RunbookUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + parameters: _models.RunbookUpdateParameters, + **kwargs: Any + ) -> _models.Runbook: """Update the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -391,49 +711,53 @@ def update( :type runbook_name: str :param parameters: The update parameters for runbook. :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Runbook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Runbook] + + _json = self._serialize.body(parameters, 'RunbookUpdateParameters') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Runbook', pipeline_response) @@ -442,16 +766,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Delete the runbook by name. :param resource_group_name: Name of an Azure Resource group. @@ -460,104 +786,121 @@ def delete( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RunbookListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.RunbookListResult]: """Retrieve a list of runbooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RunbookListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.RunbookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunbookListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RunbookListResult', pipeline_response) + deserialized = self._deserialize("RunbookListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -566,17 +909,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py index 6bd51aca5617..07b569b55b6d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,264 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + *, + json: Optional[_models.ScheduleCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + *, + json: Optional[_models.ScheduleUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ScheduleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ScheduleOperations(object): - """ScheduleOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`schedule` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - parameters, # type: "_models.ScheduleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Schedule"] + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + parameters: _models.ScheduleCreateOrUpdateParameters, + **kwargs: Any + ) -> Optional[_models.Schedule]: """Create a schedule. :param resource_group_name: Name of an Azure Resource group. @@ -64,49 +274,53 @@ def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Schedule"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.Schedule]] + + _json = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -120,17 +334,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - parameters, # type: "_models.ScheduleUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + parameters: _models.ScheduleUpdateParameters, + **kwargs: Any + ) -> _models.Schedule: """Update the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -141,49 +357,53 @@ def update( :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Schedule] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Schedule', pipeline_response) @@ -192,16 +412,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + **kwargs: Any + ) -> _models.Schedule: """Retrieve the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -210,44 +432,49 @@ def get( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Schedule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Schedule] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Schedule', pipeline_response) @@ -256,16 +483,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + **kwargs: Any + ) -> None: """Delete the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -274,104 +503,121 @@ def delete( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'scheduleName': self._serialize.url("schedule_name", schedule_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.ScheduleListResult]: """Retrieve a list of schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ScheduleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduleListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ScheduleListResult', pipeline_response) + deserialized = self._deserialize("ScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -380,17 +626,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py index 8fcd0a1009c4..9b238efee258 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_id_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + software_update_configuration_machine_run_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationMachineRunId": _SERIALIZER.url("software_update_configuration_machine_run_id", software_update_configuration_machine_run_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) -class SoftwareUpdateConfigurationMachineRunsOperations(object): - """SoftwareUpdateConfigurationMachineRunsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + *, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SoftwareUpdateConfigurationMachineRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`software_update_configuration_machine_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get_by_id( self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_machine_run_id, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationMachineRun" + resource_group_name: str, + automation_account_name: str, + software_update_configuration_machine_run_id: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationMachineRun: """Get a single software update configuration machine run by Id. :param resource_group_name: Name of an Azure Resource group. @@ -62,48 +156,52 @@ def get_by_id( :param software_update_configuration_machine_run_id: The Id of the software update configuration machine run. :type software_update_configuration_machine_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationMachineRun"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationMachineRunId': self._serialize.url("software_update_configuration_machine_run_id", software_update_configuration_machine_run_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationMachineRun] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_machine_run_id=software_update_configuration_machine_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationMachineRun', pipeline_response) @@ -112,80 +210,84 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - skip=None, # type: Optional[str] - top=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationMachineRunListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationMachineRunListResult: """Return list of software update configuration machine runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: number of entries you skip before returning results. + :param skip: number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationMachineRunListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationMachineRunListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationMachineRunListResult', pipeline_response) @@ -194,4 +296,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py index 229b49a5ca4f..c49dff76d558 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_id_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + software_update_configuration_run_id: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationRunId": _SERIALIZER.url("software_update_configuration_run_id", software_update_configuration_run_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) -class SoftwareUpdateConfigurationRunsOperations(object): - """SoftwareUpdateConfigurationRunsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + *, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SoftwareUpdateConfigurationRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`software_update_configuration_runs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get_by_id( self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_run_id, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationRun" + resource_group_name: str, + automation_account_name: str, + software_update_configuration_run_id: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationRun: """Get a single software update configuration Run by Id. :param resource_group_name: Name of an Azure Resource group. @@ -61,48 +155,52 @@ def get_by_id( :type automation_account_name: str :param software_update_configuration_run_id: The Id of the software update configuration run. :type software_update_configuration_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationRun"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationRunId': self._serialize.url("software_update_configuration_run_id", software_update_configuration_run_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationRun] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_run_id=software_update_configuration_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationRun', pipeline_response) @@ -111,80 +209,84 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - skip=None, # type: Optional[str] - top=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationRunListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationRunListResult: """Return list of software update configuration runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: Number of entries you skip before returning results. + :param skip: Number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationRunListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationRunListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationRunListResult', pipeline_response) @@ -193,4 +295,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py index 2c1b164f8096..895bcc7ea293 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,235 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + *, + json: Optional[_models.SoftwareUpdateConfiguration] = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_name_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + *, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + *, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + if client_request_id is not None: + _headers['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SoftwareUpdateConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SoftwareUpdateConfigurationsOperations(object): - """SoftwareUpdateConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`software_update_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_name, # type: str - parameters, # type: "_models.SoftwareUpdateConfiguration" - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfiguration" + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + parameters: _models.SoftwareUpdateConfiguration, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfiguration: """Create a new software update configuration with the name given in the URI. :param resource_group_name: Name of an Azure Resource group. @@ -65,53 +246,56 @@ def create( :type software_update_configuration_name: str :param parameters: Request body. :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SoftwareUpdateConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfiguration] + + _json = self._serialize.body(parameters, 'SoftwareUpdateConfiguration') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -124,17 +308,19 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace def get_by_name( self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfiguration" + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfiguration: """Get a single software update configuration by name. :param resource_group_name: Name of an Azure Resource group. @@ -144,48 +330,52 @@ def get_by_name( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfiguration] + + + request = build_get_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfiguration', pipeline_response) @@ -194,17 +384,19 @@ def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore - def delete( + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """delete a specific software update configuration. :param resource_group_name: Name of an Azure Resource group. @@ -214,115 +406,123 @@ def delete( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'softwareUpdateConfigurationName': self._serialize.url("software_update_configuration_name", software_update_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_name=software_update_configuration_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SoftwareUpdateConfigurationListResult: """Get all software update configurations for the account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwareUpdateConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwareUpdateConfigurationListResult] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SoftwareUpdateConfigurationListResult', pipeline_response) @@ -331,4 +531,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py index 86678aad8385..deaaac119daa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + *, + json: Optional[_models.SourceControlCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + *, + json: Optional[_models.SourceControlUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SourceControlOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SourceControlOperations(object): - """SourceControlOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`source_control` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - parameters, # type: "_models.SourceControlCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControl" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + parameters: _models.SourceControlCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.SourceControl: """Create a source control. :param resource_group_name: Name of an Azure Resource group. @@ -64,49 +278,53 @@ def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + _json = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,17 +337,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - parameters, # type: "_models.SourceControlUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControl" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + parameters: _models.SourceControlUpdateParameters, + **kwargs: Any + ) -> _models.SourceControl: """Update a source control. :param resource_group_name: Name of an Azure Resource group. @@ -140,49 +360,53 @@ def update( :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControl', pipeline_response) @@ -191,16 +415,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + **kwargs: Any + ) -> None: """Delete the source control. :param resource_group_name: Name of an Azure Resource group. @@ -209,59 +435,65 @@ def delete( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControl" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + **kwargs: Any + ) -> _models.SourceControl: """Retrieve the source control identified by source control name. :param resource_group_name: Name of an Azure Resource group. @@ -270,44 +502,49 @@ def get( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControl] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControl', pipeline_response) @@ -316,66 +553,80 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SourceControlListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.SourceControlListResult]: """Retrieve a list of source controls. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlListResult or the result of cls(response) + :return: An iterator like instance of either SourceControlListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlListResult', pipeline_response) + deserialized = self._deserialize("SourceControlListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -384,17 +635,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py index 8171b1602c8a..4a39dc19943b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,56 +6,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + subscription_id: str, + *, + json: Optional[_models.SourceControlSyncJobCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SourceControlSyncJobOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SourceControlSyncJobOperations(object): - """SourceControlSyncJobOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`source_control_sync_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - parameters, # type: "_models.SourceControlSyncJobCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControlSyncJob" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + parameters: _models.SourceControlSyncJobCreateParameters, + **kwargs: Any + ) -> _models.SourceControlSyncJob: """Creates the sync job for a source control. :param resource_group_name: Name of an Azure Resource group. @@ -67,50 +201,54 @@ def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJob] + + _json = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') + + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJob', pipeline_response) @@ -119,17 +257,19 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControlSyncJobById" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + **kwargs: Any + ) -> _models.SourceControlSyncJobById: """Retrieve the source control sync job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -140,45 +280,50 @@ def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobById"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobById] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJobById', pipeline_response) @@ -187,17 +332,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SourceControlSyncJobListResult"] + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.SourceControlSyncJobListResult]: """Retrieve a list of source control sync jobs. :param resource_group_name: Name of an Azure Resource group. @@ -206,51 +353,65 @@ def list_by_automation_account( :type automation_account_name: str :param source_control_name: The source control name. :type source_control_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] + :return: An iterator like instance of either SourceControlSyncJobListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlSyncJobListResult', pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -259,17 +420,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py index fb7d88085d3a..75983d0b9532 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,56 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_sync_job_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + stream_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "streamId": _SERIALIZER.url("stream_id", stream_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class SourceControlSyncJobStreamsOperations(object): - """SourceControlSyncJobStreamsOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SourceControlSyncJobStreamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`source_control_sync_job_streams` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_sync_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SourceControlSyncJobStreamsListBySyncJob"] + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.SourceControlSyncJobStreamsListBySyncJob]: """Retrieve a list of sync job streams identified by sync job id. :param resource_group_name: Name of an Azure Resource group. @@ -65,52 +154,67 @@ def list_by_sync_job( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] + :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamsListBySyncJob"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobStreamsListBySyncJob] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SourceControlSyncJobStreamsListBySyncJob', pipeline_response) + deserialized = self._deserialize("SourceControlSyncJobStreamsListBySyncJob", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,31 +223,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_sync_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams'} # type: ignore + list_by_sync_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - stream_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControlSyncJobStreamById" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + stream_id: str, + **kwargs: Any + ) -> _models.SourceControlSyncJobStreamById: """Retrieve a sync job stream identified by stream id. :param resource_group_name: Name of an Azure Resource group. @@ -156,46 +265,51 @@ def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. :type stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamById"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'streamId': self._serialize.url("stream_id", stream_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SourceControlSyncJobStreamById] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + stream_id=stream_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJobStreamById', pipeline_response) @@ -204,4 +318,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py index 2c4886e9945d..947862ac8877 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,104 +6,157 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class StatisticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StatisticsOperations(object): - """StatisticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`statistics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StatisticsListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.StatisticsListResult]: """Retrieve the statistics for the account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StatisticsListResult or the result of cls(response) + :return: An iterator like instance of either StatisticsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.StatisticsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StatisticsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StatisticsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StatisticsListResult', pipeline_response) + deserialized = self._deserialize("StatisticsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,17 +165,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py index 143df34ab9bc..f054aa4ca517 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,257 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + json: Optional[_models.TestJobCreateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_resume_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_stop_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_suspend_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class TestJobOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TestJobOperations(object): - """TestJobOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`test_job` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - parameters, # type: "_models.TestJobCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestJob" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + parameters: _models.TestJobCreateParameters, + **kwargs: Any + ) -> _models.TestJob: """Create a test job of the runbook. :param resource_group_name: Name of an Azure Resource group. @@ -63,49 +267,53 @@ def create( :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TestJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestJob] + + _json = self._serialize.body(parameters, 'TestJobCreateParameters') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -114,16 +322,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TestJob" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> _models.TestJob: """Retrieve the test job for the specified runbook. :param resource_group_name: Name of an Azure Resource group. @@ -132,44 +342,49 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestJob] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -178,16 +393,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore - def resume( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace + def resume( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Resume the test job. :param resource_group_name: Name of an Azure Resource group. @@ -196,59 +413,65 @@ def resume( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.resume.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_resume_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.resume.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume"} # type: ignore + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Stop the test job. :param resource_group_name: Name of an Azure Resource group. @@ -257,59 +480,65 @@ def stop( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_stop_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop"} # type: ignore - def suspend( + + @distributed_trace + def suspend( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Suspend the test job. :param resource_group_name: Name of an Azure Resource group. @@ -318,47 +547,53 @@ def suspend( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.suspend.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + template_url=self.suspend.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py index 0b45b5c214e1..da1b8f721834 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,139 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + job_stream_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_test_job_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') -class TestJobStreamsOperations(object): - """TestJobStreamsOperations operations. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TestJobStreamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`test_job_streams` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - job_stream_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStream" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + job_stream_id: str, + **kwargs: Any + ) -> _models.JobStream: """Retrieve a test job stream of the test job identified by runbook name and stream id. :param resource_group_name: Name of an Azure Resource group. @@ -64,45 +149,50 @@ def get( :type runbook_name: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStream"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - 'jobStreamId': self._serialize.url("job_stream_id", job_stream_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStream] - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + job_stream_id=job_stream_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobStream', pipeline_response) @@ -111,17 +201,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_test_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStreamListResult"] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.JobStreamListResult]: """Retrieve a list of test job streams identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -130,51 +222,63 @@ def list_by_test_job( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JobStreamListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_test_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobStreamListResult', pipeline_response) + deserialized = self._deserialize("JobStreamListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,17 +287,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_test_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams'} # type: ignore + list_by_test_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py index 19cf0634e982..addb816185ae 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UsageListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.UsageListResult]: """Retrieve the usage for the account id. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-22")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UsageListResult', pipeline_response) + deserialized = self._deserialize("UsageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +155,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py index 5d969e664f97..16b0dc2ce4ed 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,264 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + *, + json: Optional[_models.VariableCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + *, + json: Optional[_models.VariableUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class VariableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class VariableOperations(object): - """VariableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`variable` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - parameters, # type: "_models.VariableCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Variable" + resource_group_name: str, + automation_account_name: str, + variable_name: str, + parameters: _models.VariableCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Variable: """Create a variable. :param resource_group_name: Name of an Azure Resource group. @@ -64,49 +274,53 @@ def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + _json = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,17 +333,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - parameters, # type: "_models.VariableUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Variable" + resource_group_name: str, + automation_account_name: str, + variable_name: str, + parameters: _models.VariableUpdateParameters, + **kwargs: Any + ) -> _models.Variable: """Update a variable. :param resource_group_name: Name of an Azure Resource group. @@ -140,49 +356,53 @@ def update( :type variable_name: str :param parameters: The parameters supplied to the update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Variable', pipeline_response) @@ -191,16 +411,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + variable_name: str, + **kwargs: Any + ) -> None: """Delete the variable. :param resource_group_name: Name of an Azure Resource group. @@ -209,59 +431,65 @@ def delete( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Variable" + resource_group_name: str, + automation_account_name: str, + variable_name: str, + **kwargs: Any + ) -> _models.Variable: """Retrieve the variable identified by variable name. :param resource_group_name: Name of an Azure Resource group. @@ -270,44 +498,49 @@ def get( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Variable"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'variableName': self._serialize.url("variable_name", variable_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Variable] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Variable', pipeline_response) @@ -316,61 +549,74 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VariableListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable[_models.VariableListResult]: """Retrieve a list of variables. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VariableListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.VariableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VariableListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VariableListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VariableListResult', pipeline_response) + deserialized = self._deserialize("VariableListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -379,17 +625,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py index 0ced3fe30b63..71f7f6bc8ee4 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,55 +6,346 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + *, + json: Optional[_models.Watcher] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + *, + json: Optional[_models.WatcherUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_start_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_stop_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class WatcherOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class WatcherOperations(object): - """WatcherOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`watcher` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - parameters, # type: "_models.Watcher" - **kwargs # type: Any - ): - # type: (...) -> "_models.Watcher" + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + parameters: _models.Watcher, + **kwargs: Any + ) -> _models.Watcher: """Create the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -64,49 +356,53 @@ def create_or_update( :type watcher_name: str :param parameters: The create or update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.Watcher + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Watcher') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + _json = self._serialize.body(parameters, 'Watcher') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,16 +415,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Watcher" + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> _models.Watcher: """Retrieve the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -137,44 +435,49 @@ def get( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Watcher', pipeline_response) @@ -183,17 +486,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - parameters, # type: "_models.WatcherUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Watcher" + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + parameters: _models.WatcherUpdateParameters, + **kwargs: Any + ) -> _models.Watcher: """Update the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -204,49 +509,53 @@ def update( :type watcher_name: str :param parameters: The update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Watcher"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WatcherUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Watcher] + + _json = self._serialize.body(parameters, 'WatcherUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Watcher', pipeline_response) @@ -255,16 +564,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Delete the watcher by name. :param resource_group_name: Name of an Azure Resource group. @@ -273,59 +584,65 @@ def delete( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + - def start( + @distributed_trace + def start( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Resume the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -334,59 +651,65 @@ def start( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.start.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.start.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start"} # type: ignore + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Resume the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -395,109 +718,126 @@ def stop( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'watcherName': self._serialize.url("watcher_name", watcher_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + watcher_name=watcher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WatcherListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.WatcherListResult]: """Retrieve a list of watchers. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WatcherListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.WatcherListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WatcherListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-13-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WatcherListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WatcherListResult', pipeline_response) + deserialized = self._deserialize("WatcherListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -506,17 +846,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py index 8f6548f69bc4..1f8b276de3c9 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,351 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_generate_uri_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + *, + json: Optional[_models.WebhookCreateOrUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + *, + json: Optional[_models.WebhookUpdateParameters] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class WebhookOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class WebhookOperations(object): - """WebhookOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.automation.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.automation.AutomationClient`'s + :attr:`webhook` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def generate_uri( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> str: """Generates a Uri for use in creating a webhook. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.generate_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[str] + + + request = build_generate_uri_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_uri.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('str', pipeline_response) @@ -103,16 +359,18 @@ def generate_uri( return cls(pipeline_response, deserialized, {}) return deserialized - generate_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri'} # type: ignore - def delete( + generate_uri.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + **kwargs: Any + ) -> None: """Delete the webhook by name. :param resource_group_name: Name of an Azure Resource group. @@ -121,59 +379,65 @@ def delete( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + **kwargs: Any + ) -> _models.Webhook: """Retrieve the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -182,44 +446,49 @@ def get( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -228,17 +497,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - parameters, # type: "_models.WebhookCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + parameters: _models.WebhookCreateOrUpdateParameters, + **kwargs: Any + ) -> _models.Webhook: """Create the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -249,49 +520,53 @@ def create_or_update( :type webhook_name: str :param parameters: The create or update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + _json = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -304,17 +579,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - parameters, # type: "_models.WebhookUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + parameters: _models.WebhookUpdateParameters, + **kwargs: Any + ) -> _models.Webhook: """Update the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -325,49 +602,53 @@ def update( :type webhook_name: str :param parameters: The update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Webhook"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'webhookName': self._serialize.url("webhook_name", webhook_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Webhook] + + _json = self._serialize.body(parameters, 'WebhookUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + webhook_name=webhook_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -376,66 +657,79 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebhookListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.WebhookListResult]: """Retrieve a list of webhooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebhookListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.WebhookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-10-31")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WebhookListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WebhookListResult', pipeline_response) + deserialized = self._deserialize("WebhookListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -444,17 +738,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/setup.py b/sdk/automation/azure-mgmt-automation/setup.py index f7731c55bc02..5c446229ad7a 100644 --- a/sdk/automation/azure-mgmt-automation/setup.py +++ b/sdk/automation/azure-mgmt-automation/setup.py @@ -65,10 +65,14 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + 'azure-mgmt-core>=1.3.1,<2.0.0', ], python_requires=">=3.6" ) diff --git a/sdk/automation/azure-mgmt-automation/tests/recordings/test_cli_mgmt_automation.pyTestMgmtAutomationClienttest_automation.json b/sdk/automation/azure-mgmt-automation/tests/recordings/test_cli_mgmt_automation.pyTestMgmtAutomationClienttest_automation.json index 7683ccb6e58e..b80b4265d61b 100644 --- a/sdk/automation/azure-mgmt-automation/tests/recordings/test_cli_mgmt_automation.pyTestMgmtAutomationClienttest_automation.json +++ b/sdk/automation/azure-mgmt-automation/tests/recordings/test_cli_mgmt_automation.pyTestMgmtAutomationClienttest_automation.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.9.0b2 Python/3.6.2 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b2 Python/3.8.13 (Linux-5.13.0-1031-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -17,13 +17,13 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1753", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 09 Mar 2022 07:04:44 GMT", + "Date": "Tue, 05 Jul 2022 03:42:57 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.12529.17 - NCUS ProdSlices", - "x-ms-request-id": "cff7af64-51d1-4452-b885-71bac9bda900" + "x-ms-ests-server": "2.1.13081.9 - EUS ProdSlices", + "X-XSS-Protection": "0" }, "ResponseBody": { "token_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token", @@ -101,7 +101,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.9.0b2 Python/3.6.2 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b2 Python/3.8.13 (Linux-5.13.0-1031-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -111,13 +111,13 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 09 Mar 2022 07:04:44 GMT", + "Date": "Tue, 05 Jul 2022 03:42:57 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.12529.18 - KRSLR1 ProdSlices", - "x-ms-request-id": "6d475565-362f-4807-8a0f-5a00f52a0400" + "x-ms-ests-server": "2.1.13081.9 - WUS2 ProdSlices", + "X-XSS-Protection": "0" }, "ResponseBody": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/.well-known/openid-configuration", @@ -172,28 +172,28 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "96d44434-5f9e-4e6e-91f3-613aa8d53d1c", + "client-request-id": "09c4b76b-b28f-4a03-9892-0604f97db898", "Connection": "keep-alive", - "Content-Length": "291", + "Content-Length": "289", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.9.0b2 Python/3.6.2 (Windows-10-10.0.19041-SP0)", + "User-Agent": "azsdk-python-identity/1.11.0b2 Python/3.8.13 (Linux-5.13.0-1031-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", + "x-client-os": "linux", "x-client-sku": "MSAL.Python", - "x-client-ver": "1.17.0", + "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, - "RequestBody": "client_id=a2df54d5-ab03-4725-9b80-9a00b3b1967f\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=0vj7Q%7EIsFayrD0V_8oyOfygU-GE3ELOabq95a\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fmanagement.azure.com%2F.default", + "RequestBody": "client_id=a2df54d5-ab03-4725-9b80-9a00b3b1967f\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=0vj7Q~IsFayrD0V_8oyOfygU-GE3ELOabq95a\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fmanagement.azure.com%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "96d44434-5f9e-4e6e-91f3-613aa8d53d1c", + "client-request-id": "09c4b76b-b28f-4a03-9892-0604f97db898", "Content-Length": "93", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 09 Mar 2022 07:04:44 GMT", + "Date": "Tue, 05 Jul 2022 03:42:57 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", @@ -201,8 +201,8 @@ "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.12529.17 - SCUS ProdSlices", - "x-ms-request-id": "a5308a91-1121-4062-b012-b38d8570ef00" + "x-ms-ests-server": "2.1.13081.9 - WUS2 ProdSlices", + "X-XSS-Protection": "0" }, "ResponseBody": { "token_type": "Bearer", @@ -212,17 +212,15 @@ } }, { - "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2019-06-01", + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2021-06-22", "RequestMethod": "PUT", "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "Authorization": "Sanitized", "Connection": "keep-alive", "Content-Length": "98", "Content-Type": "application/json", - "User-Agent": "azsdk-python-mgmt-automation/1.1.0b1 Python/3.6.2 (Windows-10-10.0.19041-SP0)", - "x-ms-client-request-id": "3271b40a-9f77-11ec-95dd-c0b6f9946f2d" + "User-Agent": "azsdk-python-mgmt-automation/1.1.0b2 Python/3.8.13 (Linux-5.13.0-1031-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "name": "myAutomationAccount9", @@ -236,54 +234,61 @@ "StatusCode": 201, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "746", + "Content-Length": "1133", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 09 Mar 2022 07:04:53 GMT", + "Date": "Tue, 05 Jul 2022 03:42:58 GMT", "Expires": "-1", - "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2019-06-01", - "ocp-location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2019-06-01", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2021-06-22", "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", + "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", - "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "5d1e98a1-6942-490d-bc20-758abdf98bec", - "x-ms-location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9?api-version=2019-06-01", + "x-ms-correlation-request-id": "8933cf83-e230-4616-bdfe-04e786968020", "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-request-id": "3271b40a-9f77-11ec-95dd-c0b6f9946f2d", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220309T070454Z:5d1e98a1-6942-490d-bc20-758abdf98bec", - "X-Powered-By": "ASP.NET" + "x-ms-routing-request-id": "EASTUS2:20220705T034259Z:8933cf83-e230-4616-bdfe-04e786968020" }, "ResponseBody": { "name": "myAutomationAccount9", + "systemData": { + "createdAt": "2022-07-05T03:42:58.587\u002B00:00", + "lastModifiedAt": "2022-07-05T03:42:58.587\u002B00:00" + }, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/3fe52f16/providers/Microsoft.Automation/automationAccounts/myAutomationAccount9", "type": "Microsoft.Automation/AutomationAccounts", "location": "East US 2", "tags": {}, "etag": null, "properties": { + "disableLocalAuth": false, "sku": { "name": "Basic", "family": null, "capacity": null }, "state": "Ok", - "RegistrationUrl": "https://15ac279b-76c5-4f1f-bd52-f9386421f565.agentsvc.eus2.azure-automation.net/accounts/15ac279b-76c5-4f1f-bd52-f9386421f565", + "RegistrationUrl": "https://6e033909-98d3-445a-b2a4-1073dfed2274.agentsvc.eus2.azure-automation.net/accounts/6e033909-98d3-445a-b2a4-1073dfed2274", + "encryption": { + "keySource": "Microsoft.Automation", + "identity": { + "userAssignedIdentity": null + } + }, + "automationHybridServiceUrl": "https://6e033909-98d3-445a-b2a4-1073dfed2274.jrds.eus2.azure-automation.net/automationAccounts/6e033909-98d3-445a-b2a4-1073dfed2274", "RuntimeConfiguration": { "powershell": { "builtinModules": { - "Az": "6.5.0" + "Az": "7.3.2" } }, "powershell7": { "builtinModules": { - "Az": "6.5.0" + "Az": "7.3.2" } } }, - "creationTime": "2022-03-09T07:04:50.813\u002B00:00", + "creationTime": "2022-07-05T03:42:58.587\u002B00:00", "lastModifiedBy": null, - "lastModifiedTime": "2022-03-09T07:04:50.813\u002B00:00" + "lastModifiedTime": "2022-07-05T03:42:58.587\u002B00:00" } } }, @@ -293,10 +298,8 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "Authorization": "Sanitized", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-automation/1.1.0b1 Python/3.6.2 (Windows-10-10.0.19041-SP0)", - "x-ms-client-request-id": "389b9340-9f77-11ec-8967-c0b6f9946f2d" + "User-Agent": "azsdk-python-mgmt-automation/1.1.0b2 Python/3.8.13 (Linux-5.13.0-1031-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -304,20 +307,17 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 09 Mar 2022 07:04:54 GMT", + "Date": "Tue, 05 Jul 2022 03:42:58 GMT", "Expires": "-1", "Pragma": "no-cache", - "Server": "Microsoft-IIS/10.0", + "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", - "X-AspNet-Version": "4.0.30319", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "d53e97a1-85d1-42e2-a354-cd3a42e458c5", + "x-ms-correlation-request-id": "8cbf11b1-eec2-47ac-9e81-73178ad3fb1d", "x-ms-ratelimit-remaining-subscription-reads": "11999", - "x-ms-request-id": "389b9340-9f77-11ec-8967-c0b6f9946f2d", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220309T070454Z:d53e97a1-85d1-42e2-a354-cd3a42e458c5", - "X-Powered-By": "ASP.NET" + "x-ms-routing-request-id": "EASTUS2:20220705T034259Z:8cbf11b1-eec2-47ac-9e81-73178ad3fb1d" }, "ResponseBody": { "value": [] diff --git a/shared_requirements.txt b/shared_requirements.txt index 7f0d2716d75f..48a31a98b384 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -387,4 +387,6 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-education azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-web azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-resourceconnector azure-mgmt-core>=1.3.1,<2.0.0 +#override azure-mgmt-automation msrest>=0.6.21 +#override azure-mgmt-automation azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-rdbms azure-mgmt-core>=1.3.1,<2.0.0