From 1d8642b31abb513fa5bfbe3856fa7052161005ae Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 12 Jan 2022 07:48:15 +0000 Subject: [PATCH] CodeGen from PR 17169 in Azure/azure-rest-api-specs Add swagger definitions for deletedAutomationAccounts resource type (#17169) * add swagger definitions for deletedAutomationAccounts resource type * fix semantic and model validation error * fix model validation error * fix date format and schema type * fix lint diff error * fix paths * fix lint diff * remove errorresponse schema * add errorresponse schema * add reference in readme * supress error schema * fix URI path to return list of deleted accounts * remove automation account name parameter Co-authored-by: Ravi Yadav --- .../azure-mgmt-automation/_meta.json | 11 + .../azure/mgmt/automation/__init__.py | 9 +- .../mgmt/automation/_automation_client.py | 314 +- .../azure/mgmt/automation/_configuration.py | 19 +- .../azure/mgmt/automation/_metadata.json | 163 + .../azure/mgmt/automation/_patch.py | 31 + .../azure/mgmt/automation/_vendor.py | 27 + .../azure/mgmt/automation/_version.py | 2 +- .../azure/mgmt/automation/aio/__init__.py | 5 + .../mgmt/automation/aio/_automation_client.py | 303 +- .../mgmt/automation/aio/_configuration.py | 6 +- .../azure/mgmt/automation/aio/_patch.py | 31 + .../automation/aio/operations/__init__.py | 56 +- .../aio/operations/_activity_operations.py | 105 +- ...ent_registration_information_operations.py | 86 +- .../_automation_account_operations.py | 269 +- .../_automation_client_operations.py | 85 + .../aio/operations/_certificate_operations.py | 229 +- .../aio/operations/_connection_operations.py | 229 +- .../operations/_connection_type_operations.py | 184 +- .../aio/operations/_credential_operations.py | 227 +- .../_dsc_compilation_job_operations.py | 224 +- .../_dsc_compilation_job_stream_operations.py | 45 +- .../_dsc_configuration_operations.py | 327 +- .../_dsc_node_configuration_operations.py | 235 +- .../aio/operations/_dsc_node_operations.py | 197 +- .../aio/operations/_fields_operations.py | 69 +- ..._hybrid_runbook_worker_group_operations.py | 257 +- .../_hybrid_runbook_workers_operations.py | 384 ++ .../aio/operations/_job_operations.py | 355 +- .../operations/_job_schedule_operations.py | 188 +- .../aio/operations/_job_stream_operations.py | 116 +- .../aio/operations/_keys_operations.py | 43 +- .../_linked_workspace_operations.py | 43 +- .../aio/operations/_module_operations.py | 223 +- .../_node_count_information_operations.py | 45 +- .../operations/_node_reports_operations.py | 159 +- .../_object_data_types_operations.py | 126 +- .../automation/aio/operations/_operations.py | 49 +- ...private_endpoint_connections_operations.py | 406 ++ .../_private_link_resources_operations.py | 122 + .../operations/_python2_package_operations.py | 223 +- .../operations/_runbook_draft_operations.py | 244 +- .../aio/operations/_runbook_operations.py | 336 +- .../aio/operations/_schedule_operations.py | 226 +- ...e_configuration_machine_runs_operations.py | 99 +- ...re_update_configuration_runs_operations.py | 99 +- ...ftware_update_configurations_operations.py | 182 +- .../operations/_source_control_operations.py | 233 +- .../_source_control_sync_job_operations.py | 159 +- ...rce_control_sync_job_streams_operations.py | 117 +- .../aio/operations/_statistics_operations.py | 70 +- .../aio/operations/_test_job_operations.py | 198 +- .../_test_job_streams_operations.py | 109 +- .../aio/operations/_usages_operations.py | 60 +- .../aio/operations/_variable_operations.py | 226 +- .../aio/operations/_watcher_operations.py | 302 +- .../aio/operations/_webhook_operations.py | 265 +- .../azure/mgmt/automation/models/__init__.py | 534 +- .../models/_automation_client_enums.py | 115 +- .../azure/mgmt/automation/models/_models.py | 6099 ----------------- .../mgmt/automation/models/_models_py3.py | 5089 ++++++++++---- .../mgmt/automation/operations/__init__.py | 56 +- .../operations/_activity_operations.py | 205 +- ...ent_registration_information_operations.py | 194 +- .../_automation_account_operations.py | 537 +- .../_automation_client_operations.py | 132 + .../operations/_certificate_operations.py | 486 +- .../operations/_connection_operations.py | 486 +- .../operations/_connection_type_operations.py | 384 +- .../operations/_credential_operations.py | 484 +- .../_dsc_compilation_job_operations.py | 445 +- .../_dsc_compilation_job_stream_operations.py | 103 +- .../_dsc_configuration_operations.py | 651 +- .../_dsc_node_configuration_operations.py | 470 +- .../operations/_dsc_node_operations.py | 418 +- .../operations/_fields_operations.py | 127 +- ..._hybrid_runbook_worker_group_operations.py | 510 +- .../_hybrid_runbook_workers_operations.py | 601 ++ .../automation/operations/_job_operations.py | 794 ++- .../operations/_job_schedule_operations.py | 394 +- .../operations/_job_stream_operations.py | 233 +- .../automation/operations/_keys_operations.py | 97 +- .../_linked_workspace_operations.py | 97 +- .../operations/_module_operations.py | 483 +- .../_node_count_information_operations.py | 103 +- .../operations/_node_reports_operations.py | 317 +- .../_object_data_types_operations.py | 223 +- .../mgmt/automation/operations/_operations.py | 85 +- ...private_endpoint_connections_operations.py | 562 ++ .../_private_link_resources_operations.py | 158 + .../operations/_python2_package_operations.py | 483 +- .../operations/_runbook_draft_operations.py | 451 +- .../operations/_runbook_operations.py | 690 +- .../operations/_schedule_operations.py | 483 +- ...e_configuration_machine_runs_operations.py | 222 +- ...re_update_configuration_runs_operations.py | 222 +- ...ftware_update_configurations_operations.py | 414 +- .../operations/_source_control_operations.py | 496 +- .../_source_control_sync_job_operations.py | 334 +- ...rce_control_sync_job_streams_operations.py | 234 +- .../operations/_statistics_operations.py | 126 +- .../operations/_test_job_operations.py | 452 +- .../_test_job_streams_operations.py | 215 +- .../operations/_usages_operations.py | 113 +- .../operations/_variable_operations.py | 483 +- .../operations/_watcher_operations.py | 657 +- .../operations/_webhook_operations.py | 570 +- 108 files changed, 20503 insertions(+), 16966 deletions(-) create mode 100644 sdk/automation/azure-mgmt-automation/_meta.json create mode 100644 sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_metadata.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/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/_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/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/_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/_meta.json b/sdk/automation/azure-mgmt-automation/_meta.json new file mode 100644 index 0000000000000..df7de0ed3dd72 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "cc7ba44cc488da87e751eb337d1d212df10445a9", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/automation/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.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 29580d4d1d847..927665976a334 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AutomationClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 aa9b40978ef35..ffb5b612d4514 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,58 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential -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 - - -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): """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 +74,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 +89,139 @@ 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._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.agent_registration_information = AgentRegistrationInformationOperations(self._client, self._config, self._serialize, self._deserialize) + self.dsc_node = DscNodeOperations(self._client, self._config, self._serialize, self._deserialize) + self.node_reports = NodeReportsOperations(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.dsc_compilation_job_stream = DscCompilationJobStreamOperations(self._client, self._config, self._serialize, self._deserialize) + self.node_count_information = NodeCountInformationOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control = SourceControlOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_sync_job = SourceControlSyncJobOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_sync_job_streams = SourceControlSyncJobStreamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.automation_account = AutomationAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.statistics = StatisticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection = ConnectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection_type = ConnectionTypeOperations(self._client, self._config, self._serialize, self._deserialize) + self.credential = CredentialOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_schedule = JobScheduleOperations(self._client, self._config, self._serialize, self._deserialize) + self.linked_workspace = LinkedWorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity = ActivityOperations(self._client, self._config, self._serialize, self._deserialize) + self.module = ModuleOperations(self._client, self._config, self._serialize, self._deserialize) + self.object_data_types = ObjectDataTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.fields = FieldsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedule = ScheduleOperations(self._client, self._config, self._serialize, self._deserialize) + self.variable = VariableOperations(self._client, self._config, self._serialize, self._deserialize) + self.watcher = WatcherOperations(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.hybrid_runbook_workers = HybridRunbookWorkersOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: 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 + """ - 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.python2_package = Python2PackageOperations( - self._client, self._config, self._serialize, self._deserialize) - self.agent_registration_information = AgentRegistrationInformationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_node = DscNodeOperations( - self._client, self._config, self._serialize, self._deserialize) - self.node_reports = NodeReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_compilation_job = DscCompilationJobOperations( - 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.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.source_control = SourceControlOperations( - self._client, self._config, self._serialize, self._deserialize) - self.source_control_sync_job = SourceControlSyncJobOperations( - 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.automation_account = AutomationAccountOperations( - self._client, self._config, self._serialize, self._deserialize) - self.statistics = StatisticsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.keys = KeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificate = CertificateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.connection = ConnectionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.connection_type = ConnectionTypeOperations( - 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.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_schedule = JobScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.linked_workspace = LinkedWorkspaceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.activity = ActivityOperations( - self._client, self._config, self._serialize, self._deserialize) - self.module = ModuleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.object_data_types = ObjectDataTypesOperations( - 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.schedule = ScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.variable = VariableOperations( - self._client, self._config, self._serialize, self._deserialize) - self.watcher = WatcherOperations( - self._client, self._config, self._serialize, self._deserialize) - self.webhook = WebhookOperations( - self._client, self._config, self._serialize, self._deserialize) + 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 b9e9ba1a61512..b23403bb18c25 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py @@ -6,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class AutomationClientConfiguration(Configuration): 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 +64,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/_metadata.json b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_metadata.json new file mode 100644 index 0000000000000..f94c3c6945af7 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_metadata.json @@ -0,0 +1,163 @@ +{ + "chosen_version": "", + "total_api_version_list": ["2015-10-31", "2018-06-30", "2019-06-01", "2020-01-13-preview", "2021-06-22"], + "client": { + "name": "AutomationClient", + "filename": "_automation_client", + "description": "Automation Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AutomationClientConfiguration\"], \"._operations_mixin\": [\"AutomationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AutomationClientConfiguration\"], \"._operations_mixin\": [\"AutomationClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "python2_package": "Python2PackageOperations", + "agent_registration_information": "AgentRegistrationInformationOperations", + "dsc_node": "DscNodeOperations", + "node_reports": "NodeReportsOperations", + "dsc_node_configuration": "DscNodeConfigurationOperations", + "dsc_compilation_job": "DscCompilationJobOperations", + "dsc_compilation_job_stream": "DscCompilationJobStreamOperations", + "node_count_information": "NodeCountInformationOperations", + "source_control": "SourceControlOperations", + "source_control_sync_job": "SourceControlSyncJobOperations", + "source_control_sync_job_streams": "SourceControlSyncJobStreamsOperations", + "automation_account": "AutomationAccountOperations", + "statistics": "StatisticsOperations", + "usages": "UsagesOperations", + "keys": "KeysOperations", + "certificate": "CertificateOperations", + "connection": "ConnectionOperations", + "connection_type": "ConnectionTypeOperations", + "credential": "CredentialOperations", + "hybrid_runbook_worker_group": "HybridRunbookWorkerGroupOperations", + "job_schedule": "JobScheduleOperations", + "linked_workspace": "LinkedWorkspaceOperations", + "activity": "ActivityOperations", + "module": "ModuleOperations", + "object_data_types": "ObjectDataTypesOperations", + "fields": "FieldsOperations", + "schedule": "ScheduleOperations", + "variable": "VariableOperations", + "watcher": "WatcherOperations", + "dsc_configuration": "DscConfigurationOperations", + "job": "JobOperations", + "job_stream": "JobStreamOperations", + "operations": "Operations", + "software_update_configurations": "SoftwareUpdateConfigurationsOperations", + "software_update_configuration_runs": "SoftwareUpdateConfigurationRunsOperations", + "software_update_configuration_machine_runs": "SoftwareUpdateConfigurationMachineRunsOperations", + "runbook_draft": "RunbookDraftOperations", + "runbook": "RunbookOperations", + "test_job_streams": "TestJobStreamsOperations", + "test_job": "TestJobOperations", + "webhook": "WebhookOperations", + "hybrid_runbook_workers": "HybridRunbookWorkersOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "operations": { + "convert_graph_runbook_content" : { + "sync": { + "signature": "def convert_graph_runbook_content(\n self,\n resource_group_name, # type: str\n automation_account_name, # type: str\n parameters, # type: \"_models.GraphicalRunbookContent\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.GraphicalRunbookContent\"\n", + "doc": "\"\"\"Post operation to serialize or deserialize GraphRunbookContent.\n\n:param resource_group_name: Name of an Azure Resource group.\n:type resource_group_name: str\n:param automation_account_name: The name of the automation account.\n:type automation_account_name: str\n:param parameters: Input data describing the graphical runbook.\n:type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GraphicalRunbookContent, or the result of cls(response)\n:rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def convert_graph_runbook_content(\n self,\n resource_group_name: str,\n automation_account_name: str,\n parameters: \"_models.GraphicalRunbookContent\",\n **kwargs: Any\n) -\u003e \"_models.GraphicalRunbookContent\":\n", + "doc": "\"\"\"Post operation to serialize or deserialize GraphRunbookContent.\n\n:param resource_group_name: Name of an Azure Resource group.\n:type resource_group_name: str\n:param automation_account_name: The name of the automation account.\n:type automation_account_name: str\n:param parameters: Input data describing the graphical runbook.\n:type parameters: ~azure.mgmt.automation.models.GraphicalRunbookContent\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GraphicalRunbookContent, or the result of cls(response)\n:rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "resource_group_name, automation_account_name, parameters" + } + } + } +} \ No newline at end of file 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 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_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 azure.core.pipeline.transport import HttpRequest + +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) 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 653b73a4a1994..e5754a47ce68f 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.0.0b1" 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 c537136a35f89..f67ad3868dd37 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 @@ -8,3 +8,8 @@ from ._automation_client import AutomationClient __all__ = ['AutomationClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 0468a4e97c2e3..2aeeee4750cf8 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,58 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): """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 +74,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 +89,139 @@ 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._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.agent_registration_information = AgentRegistrationInformationOperations(self._client, self._config, self._serialize, self._deserialize) + self.dsc_node = DscNodeOperations(self._client, self._config, self._serialize, self._deserialize) + self.node_reports = NodeReportsOperations(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.dsc_compilation_job_stream = DscCompilationJobStreamOperations(self._client, self._config, self._serialize, self._deserialize) + self.node_count_information = NodeCountInformationOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control = SourceControlOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_sync_job = SourceControlSyncJobOperations(self._client, self._config, self._serialize, self._deserialize) + self.source_control_sync_job_streams = SourceControlSyncJobStreamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.automation_account = AutomationAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.statistics = StatisticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection = ConnectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.connection_type = ConnectionTypeOperations(self._client, self._config, self._serialize, self._deserialize) + self.credential = CredentialOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_schedule = JobScheduleOperations(self._client, self._config, self._serialize, self._deserialize) + self.linked_workspace = LinkedWorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity = ActivityOperations(self._client, self._config, self._serialize, self._deserialize) + self.module = ModuleOperations(self._client, self._config, self._serialize, self._deserialize) + self.object_data_types = ObjectDataTypesOperations(self._client, self._config, self._serialize, self._deserialize) + self.fields = FieldsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedule = ScheduleOperations(self._client, self._config, self._serialize, self._deserialize) + self.variable = VariableOperations(self._client, self._config, self._serialize, self._deserialize) + self.watcher = WatcherOperations(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.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 + """ - 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.python2_package = Python2PackageOperations( - self._client, self._config, self._serialize, self._deserialize) - self.agent_registration_information = AgentRegistrationInformationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_node = DscNodeOperations( - self._client, self._config, self._serialize, self._deserialize) - self.node_reports = NodeReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dsc_compilation_job = DscCompilationJobOperations( - 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.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.source_control = SourceControlOperations( - self._client, self._config, self._serialize, self._deserialize) - self.source_control_sync_job = SourceControlSyncJobOperations( - 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.automation_account = AutomationAccountOperations( - self._client, self._config, self._serialize, self._deserialize) - self.statistics = StatisticsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.keys = KeysOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificate = CertificateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.connection = ConnectionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.connection_type = ConnectionTypeOperations( - 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.hybrid_runbook_worker_group = HybridRunbookWorkerGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.job_schedule = JobScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.linked_workspace = LinkedWorkspaceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.activity = ActivityOperations( - self._client, self._config, self._serialize, self._deserialize) - self.module = ModuleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.object_data_types = ObjectDataTypesOperations( - 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.schedule = ScheduleOperations( - self._client, self._config, self._serialize, self._deserialize) - self.variable = VariableOperations( - self._client, self._config, self._serialize, self._deserialize) - self.watcher = WatcherOperations( - self._client, self._config, self._serialize, self._deserialize) - self.webhook = WebhookOperations( - self._client, self._config, self._serialize, self._deserialize) + 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 dce38b50c718e..f5701b0c3741e 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 @@ -37,11 +37,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 +63,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 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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 d7371312a9c81..23136da95dd4b 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,38 @@ 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 __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 +74,6 @@ 'ConnectionOperations', 'ConnectionTypeOperations', 'CredentialOperations', - 'DscConfigurationOperations', - 'SoftwareUpdateConfigurationsOperations', 'HybridRunbookWorkerGroupOperations', 'JobScheduleOperations', 'LinkedWorkspaceOperations', @@ -85,9 +81,21 @@ 'ModuleOperations', 'ObjectDataTypesOperations', 'FieldsOperations', - 'Operations', 'ScheduleOperations', 'VariableOperations', 'WatcherOperations', + 'DscConfigurationOperations', + 'JobOperations', + 'JobStreamOperations', + 'Operations', + 'AutomationClientOperationsMixin', + 'SoftwareUpdateConfigurationsOperations', + 'SoftwareUpdateConfigurationRunsOperations', + 'SoftwareUpdateConfigurationMachineRunsOperations', + 'RunbookDraftOperations', + 'RunbookOperations', + 'TestJobStreamsOperations', + 'TestJobOperations', 'WebhookOperations', + 'HybridRunbookWorkersOperations', ] 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 f3fd231d02574..2effd657e6665 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, module_name: str, activity_name: str, - **kwargs + **kwargs: Any ) -> "_models.Activity": """Retrieve the activity in the module identified by module name and activity name. @@ -69,35 +75,25 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,14 +102,17 @@ 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 + + @distributed_trace def list_by_module( self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ActivityListResult"]: """Retrieve a list of activities in the module identified by module name. @@ -125,7 +124,8 @@ def list_by_module( :type module_name: 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"] @@ -133,37 +133,35 @@ def list_by_module( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_module.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -176,12 +174,13 @@ async def get_next(next_link=None): 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 ) 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 c0f984e15215c..d2fed15000b90 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> "_models.AgentRegistration": """Retrieve the automation agent registration information. @@ -62,33 +67,23 @@ async def get( 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,14 +92,17 @@ 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 + + @distributed_trace_async async def regenerate_key( self, resource_group_name: str, automation_account_name: str, parameters: "_models.AgentRegistrationRegenerateKeyParameter", - **kwargs + **kwargs: Any ) -> "_models.AgentRegistration": """Regenerate a primary or secondary agent registration key. @@ -124,38 +122,28 @@ async def regenerate_key( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - # 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') + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +152,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 + 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 c46bc8efda84d..9f0de82c8f996 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, parameters: "_models.AutomationAccountUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.AutomationAccount": """Update an automation account. @@ -66,38 +72,28 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +102,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + 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 + **kwargs: Any ) -> "_models.AutomationAccount": """Create or update automation account. @@ -133,38 +132,28 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +166,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete an automation account. @@ -201,33 +193,23 @@ async def delete( 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) - - # 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 = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -235,11 +217,13 @@ async def delete( 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 + **kwargs: Any ) -> "_models.AutomationAccount": """Get information about an Automation Account. @@ -257,33 +241,23 @@ async def get( 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 = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,20 +266,25 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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 + **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 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"] @@ -313,35 +292,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -354,28 +329,32 @@ async def get_next(next_link=None): 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 + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AutomationAccountListResult"]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. :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"] @@ -383,34 +362,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -423,12 +397,13 @@ async def get_next(next_link=None): 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 ) 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 0000000000000..712b0be6baaa1 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py @@ -0,0 +1,85 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AutomationClientOperationsMixin: + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GraphicalRunbookContent"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.convert_graph_runbook_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 9550ca4ad5a9d..0c14de8800240 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, certificate_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the certificate. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Certificate": """Retrieve the certificate identified by certificate name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, certificate_name: str, parameters: "_models.CertificateCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Certificate": """Create a certificate. @@ -192,39 +183,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +218,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}/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 + **kwargs: Any ) -> "_models.Certificate": """Update a certificate. @@ -267,39 +251,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CertificateListResult"]: """Retrieve a list of certificates. @@ -323,8 +300,10 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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"] @@ -332,36 +311,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -374,12 +350,13 @@ async def get_next(next_link=None): 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 ) 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 cfaacdf48919c..7fa669ea758eb 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, connection_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Connection": """Retrieve the connection identified by connection name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, connection_name: str, parameters: "_models.ConnectionCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Connection": """Create or update a connection. @@ -192,39 +183,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +218,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}/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 + **kwargs: Any ) -> "_models.Connection": """Update a connection. @@ -267,39 +251,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConnectionListResult"]: """Retrieve a list of connections. @@ -323,8 +300,10 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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"] @@ -332,36 +311,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -374,12 +350,13 @@ async def get_next(next_link=None): 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 ) 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 921ca73acdfda..3097a4dd7376a 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection type. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.ConnectionType": """Retrieve the connection type identified by connection type name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @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 + **kwargs: Any ) -> "_models.ConnectionType": """Create a connection type. @@ -193,39 +184,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +215,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}/connectionTypes/{connectionTypeName}'} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConnectionTypeListResult"]: """Retrieve a list of connection types. @@ -249,8 +233,10 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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"] @@ -258,36 +244,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -300,12 +283,13 @@ async def get_next(next_link=None): 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 ) 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 b70ff90697ffb..9ec5dfe0aabf9 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, credential_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the credential. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Credential": """Retrieve the credential identified by credential name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, credential_name: str, parameters: "_models.CredentialCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Credential": """Create a credential. @@ -192,39 +183,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +218,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}/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 + **kwargs: Any ) -> "_models.Credential": """Update a credential. @@ -267,39 +251,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CredentialListResult"]: """Retrieve a list of credentials. @@ -323,8 +300,10 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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"] @@ -332,36 +311,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -379,6 +355,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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 bd5b087ef960f..a2804fe2dc6c5 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 @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,47 +54,36 @@ async def _create_initial( automation_account_name: str, compilation_job_name: str, parameters: "_models.DscCompilationJobCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.DscCompilationJob": 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" - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +91,18 @@ 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 + + @distributed_trace_async async def begin_create( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, parameters: "_models.DscCompilationJobCreateParameters", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DscCompilationJob"]: """Creates the Dsc compilation job of the configuration. @@ -119,15 +116,19 @@ async def begin_create( :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( 'polling_interval', @@ -140,28 +141,21 @@ async def begin_create( automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -173,14 +167,16 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, - **kwargs + **kwargs: Any ) -> "_models.DscCompilationJob": """Retrieve the Dsc configuration compilation job identified by job id. @@ -200,34 +196,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,14 +222,17 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DscCompilationJobListResult"]: """Retrieve a list of dsc compilation jobs. @@ -254,8 +243,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -263,38 +254,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -307,24 +295,26 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get_stream( self, resource_group_name: str, automation_account_name: str, job_id: str, job_stream_id: str, - **kwargs + **kwargs: Any ) -> "_models.JobStream": """Retrieve the job stream identified by job stream id. @@ -346,35 +336,25 @@ async def get_stream( 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') + + 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, + template_url=self.get_stream.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +363,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 + 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 b5ceebb497b1d..6468b36e53eb9 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,12 +44,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_job( self, resource_group_name: str, automation_account_name: str, job_id: str, - **kwargs + **kwargs: Any ) -> "_models.JobStreamListResult": """Retrieve all the job streams for the compilation Job. @@ -65,34 +70,24 @@ async def list_by_job( 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 = 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, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +96,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 + 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 fa2cc5f3e6a95..207bfbf7aba6b 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc configuration identified by configuration name. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.DscConfiguration": """Retrieve the configuration identified by configuration name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @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 + **kwargs: Any ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. @@ -182,8 +173,8 @@ 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 str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "text/plain; charset=utf-8", "application/json." :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 @@ -194,48 +185,40 @@ async def create_or_update( 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 + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = None + _content = None + 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) + + 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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,15 +231,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}/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 + **kwargs: Any ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. @@ -268,8 +254,8 @@ async def update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :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 str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "text/plain; charset=utf-8", "application/json." :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 @@ -280,51 +266,40 @@ async def update( 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 + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = None + _content = None + 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) + + 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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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 +308,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 + + @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. @@ -360,28 +338,18 @@ async def get_content( 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) - - # 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 = 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -395,8 +363,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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -405,7 +376,7 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DscConfigurationListResult"]: """Retrieve a list of configurations. @@ -422,8 +393,10 @@ def list_by_automation_account( :param inlinecount: Return total rows. :type inlinecount: 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"] @@ -431,44 +404,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -481,12 +451,13 @@ async def get_next(next_link=None): 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 ) 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 1b76e60c61100..1387c61c83b91 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 @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,12 +48,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( 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. @@ -68,34 +74,24 @@ async def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -103,12 +99,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.DscNodeConfiguration": """Retrieve the Dsc node configurations by node configuration. @@ -128,34 +126,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +152,46 @@ 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 + async def _create_or_update_initial( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, parameters: "_models.DscNodeConfigurationCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.DscNodeConfiguration"]: cls = kwargs.pop('cls', None) # type: ClsType[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +201,18 @@ 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 + + @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 + **kwargs: Any ) -> AsyncLROPoller["_models.DscNodeConfiguration"]: """Create the node configuration identified by node configuration name. @@ -244,15 +226,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( 'polling_interval', @@ -265,28 +251,21 @@ async def begin_create_or_update( automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -298,8 +277,10 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -308,7 +289,7 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DscNodeConfigurationListResult"]: """Retrieve a list of dsc node configurations. @@ -325,8 +306,10 @@ def list_by_automation_account( :param inlinecount: Return total rows. :type inlinecount: 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"] @@ -334,44 +317,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -384,12 +364,13 @@ async def get_next(next_link=None): 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 ) 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 c57d748bf2eec..de32e5cc93364 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, node_id: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc node identified by node id. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.DscNode": """Retrieve the dsc node identified by node id. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @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 + **kwargs: Any ) -> "_models.DscNode": """Update the dsc node. @@ -192,39 +183,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +214,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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -243,7 +227,7 @@ def list_by_automation_account( skip: Optional[int] = None, top: Optional[int] = None, inlinecount: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DscNodeListResult"]: """Retrieve a list of dsc nodes. @@ -261,7 +245,8 @@ def list_by_automation_account( :type inlinecount: 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"] @@ -269,44 +254,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -319,12 +301,13 @@ async def get_next(next_link=None): 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 ) 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 46dad59080543..98f7ef44a019e 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_type( self, resource_group_name: str, automation_account_name: str, module_name: str, type_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.TypeFieldListResult"]: """Retrieve a list of fields of a given type identified by module name. @@ -61,7 +67,8 @@ def list_by_type( :type type_name: 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"] @@ -69,38 +76,37 @@ def list_by_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -113,12 +119,13 @@ async def get_next(next_link=None): 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 ) 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 26bbf388d5788..a913d60f0b509 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( 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. @@ -66,34 +72,24 @@ async def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.HybridRunbookWorkerGroup": """Retrieve a hybrid runbook worker group. @@ -126,34 +124,90 @@ async def get( 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'), + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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) + + 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_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. + + :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 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 } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _json = self._serialize.body(hybrid_runbook_worker_group_creation_parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +216,18 @@ 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 + parameters: "_models.HybridRunbookWorkerGroupCreateOrUpdateParameters", + **kwargs: Any ) -> "_models.HybridRunbookWorkerGroup": """Update a hybrid runbook worker group. @@ -181,7 +238,8 @@ 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 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 @@ -192,39 +250,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +281,17 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.HybridRunbookWorkerGroupsListResult"]: """Retrieve a list of hybrid runbook worker groups. @@ -251,8 +302,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -260,38 +313,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -304,12 +354,13 @@ async def get_next(next_link=None): 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 ) 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 0000000000000..eb40c200d0d1a --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,384 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class HybridRunbookWorkersOperations: + """HybridRunbookWorkersOperations 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. + + :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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def delete( + 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 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', {})) + + + 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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. + :type filter: 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkersListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 e0d98349d7c7e..76b2388c6264a 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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. @@ -69,30 +75,19 @@ async def get_output( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -106,15 +101,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 + + @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. @@ -136,30 +134,19 @@ async def get_runbook_content( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -173,15 +160,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 + + @distributed_trace_async async def suspend( 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. @@ -203,36 +193,25 @@ async def suspend( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -240,13 +219,15 @@ async def suspend( suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + + @distributed_trace_async async def stop( 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. @@ -268,36 +249,25 @@ async def stop( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -305,13 +275,15 @@ async def stop( 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 + **kwargs: Any ) -> "_models.Job": """Retrieve the job identified by job name. @@ -333,36 +305,25 @@ async def get( 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') + + 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, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +332,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}'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -380,7 +344,7 @@ async def create( job_name: str, parameters: "_models.JobCreateParameters", client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Job": """Create a job of the runbook. @@ -404,41 +368,30 @@ async def create( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,15 +400,18 @@ 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 + + @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 + **kwargs: Any ) -> AsyncIterable["_models.JobListResultV2"]: """Retrieve a list of jobs. @@ -477,40 +433,37 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -523,24 +476,26 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def resume( 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. @@ -562,39 +517,29 @@ async def resume( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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 fe0c83b3f10e2..d9e06542553c4 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( 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. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.JobSchedule": """Retrieve the job schedule identified by job schedule name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, parameters: "_models.JobScheduleCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.JobSchedule": """Create a job schedule. @@ -192,39 +183,29 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'JobScheduleCreateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +214,17 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.JobScheduleListResult"]: """Retrieve a list of job schedules. @@ -251,8 +235,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -260,38 +246,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -304,12 +287,13 @@ async def get_next(next_link=None): 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 ) 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 7a79fe7c37507..fc061281e7c42 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -48,7 +54,7 @@ async def get( job_name: str, job_stream_id: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.JobStream": """Retrieve the job stream identified by job stream id. @@ -72,37 +78,26 @@ async def get( 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') + + 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, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +106,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 + + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -120,7 +118,7 @@ def list_by_job( job_name: str, filter: Optional[str] = None, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.JobStreamListResult"]: """Retrieve a list of jobs streams identified by job name. @@ -136,7 +134,8 @@ def list_by_job( :type client_request_id: 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"] @@ -144,41 +143,39 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -191,12 +188,13 @@ async def get_next(next_link=None): 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 ) 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 580c72ba99ef9..81f1c278ad05a 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> "_models.KeyListResult": """Retrieve the automation keys for an account. @@ -62,33 +67,23 @@ async def list_by_automation_account( 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 = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +92,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 + 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 d7b7686e96cec..8504736309df1 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._linked_workspace_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> "_models.LinkedWorkspace": """Retrieve the linked workspace for the account id. @@ -62,33 +67,23 @@ async def get( 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 = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +92,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 + 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 13311f1183662..173ead0346fdd 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the module by name. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Module": """Retrieve the module identified by module name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,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}'} # 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 + **kwargs: Any ) -> "_models.Module": """Create or Update the module identified by module name. @@ -192,39 +183,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +218,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}/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 + **kwargs: Any ) -> "_models.Module": """Update the module identified by module name. @@ -267,39 +251,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ModuleListResult"]: """Retrieve a list of modules. @@ -332,36 +309,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -374,12 +348,13 @@ async def get_next(next_link=None): 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 ) 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 aec38db500256..77e261a3cd8c7 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,12 +44,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, count_type: Union[str, "_models.CountType"], - **kwargs + **kwargs: Any ) -> "_models.NodeCounts": """Retrieve counts for Dsc Nodes. @@ -65,34 +70,24 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +96,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 + 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 48789a3db04df..383b7f2d9d253 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_node( self, resource_group_name: str, automation_account_name: str, node_id: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.DscNodeReportListResult"]: """Retrieve the Dsc node report list by node id. @@ -60,8 +66,10 @@ def list_by_node( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -69,39 +77,37 @@ def list_by_node( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_node.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -114,24 +120,26 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, - **kwargs + **kwargs: Any ) -> "_models.DscNodeReport": """Retrieve the Dsc node report data by node id and report id. @@ -153,35 +161,25 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +188,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 + + @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. @@ -211,44 +212,34 @@ async def get_content( :param report_id: The report id. :type report_id: 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] + cls = kwargs.pop('cls', None) # type: ClsType[Any] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +248,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 + 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 35507366f3720..6576401836dbe 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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 + **kwargs: Any ) -> AsyncIterable["_models.TypeFieldListResult"]: """Retrieve a list of fields of a given type identified by module name. @@ -61,7 +67,8 @@ def list_fields_by_module_and_type( :type type_name: 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"] @@ -69,38 +76,37 @@ def list_fields_by_module_and_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_fields_by_module_and_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -113,23 +119,25 @@ async def get_next(next_link=None): 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 + @distributed_trace def list_fields_by_type( self, resource_group_name: str, automation_account_name: str, type_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.TypeFieldListResult"]: """Retrieve a list of fields of a given type across all accessible modules. @@ -141,7 +149,8 @@ def list_fields_by_type( :type type_name: 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"] @@ -149,37 +158,35 @@ def list_fields_by_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_fields_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -192,12 +199,13 @@ async def get_next(next_link=None): 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 ) 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 5646e67f5ae18..5571a61057e7f 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available Automation REST API operations. :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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 ) 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 0000000000000..9445bc0b46474 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,406 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +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.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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateEndpointConnectionsOperations: + """PrivateEndpointConnectionsOperations 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. + + :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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 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 + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + 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( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = 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 + ) + 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}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **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', {})) + + + 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, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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( + 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 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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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._delete_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x,y,z: x, + **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 = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + 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 0000000000000..15948f996fa49 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,122 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateLinkResourcesOperations: + """PrivateLinkResourcesOperations 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. + + :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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.automation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 b4753198f4b63..4ecc7638bce5b 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, package_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the python 2 package by name. @@ -66,34 +72,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -101,12 +97,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Module": """Retrieve the python 2 package identified by package name. @@ -126,34 +124,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +150,18 @@ 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, package_name: str, parameters: "_models.PythonPackageCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.Module": """Create or Update the python 2 package identified by package name. @@ -192,39 +183,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PythonPackageCreateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +218,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}/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 + **kwargs: Any ) -> "_models.Module": """Update the python 2 package identified by package name. @@ -267,39 +251,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ModuleListResult"]: """Retrieve a list of python 2 packages. @@ -332,36 +309,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -374,12 +348,13 @@ async def get_next(next_link=None): 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 ) 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 5118a9366302d..69af905727e01 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 @@ -5,18 +5,22 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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. @@ -58,37 +63,27 @@ async def get_content( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType[IO] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -96,79 +91,79 @@ async def get_content( 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 + async def _replace_content_initial( self, resource_group_name: str, automation_account_name: str, runbook_name: str, runbook_content: str, - **kwargs - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] + **kwargs: Any + ) -> Optional[IO]: + cls = kwargs.pop('cls', None) # type: ClsType[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') + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[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') + _content = runbook_content - 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) + 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, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(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 + + @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,20 +172,23 @@ 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 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[IO] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -202,25 +200,21 @@ async def begin_replace_content( automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -232,14 +226,16 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> "_models.RunbookDraft": """Retrieve the runbook draft identified by runbook name. @@ -259,34 +255,24 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +281,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 + + @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. @@ -313,46 +302,41 @@ async def undo_edit( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookDraftUndoEditResult"] 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') + + 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, + template_url=self.undo_edit.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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 bed2db8ae7951..2453d31187bb3 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 @@ -5,19 +5,24 @@ # 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, IO, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,57 +53,49 @@ async def _publish_initial( 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) - - # 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 = 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, + template_url=self._publish_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + + @distributed_trace_async async def begin_publish( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Publish runbook draft. @@ -110,15 +107,17 @@ async def begin_publish( :type runbook_name: 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] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -133,22 +132,14 @@ async def begin_publish( cls=lambda x,y,z: x, **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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -160,15 +151,17 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -178,37 +171,27 @@ async def get_content( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType[IO] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -216,20 +199,23 @@ async def get_content( 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 + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> "_models.Runbook": """Retrieve the runbook identified by runbook name. @@ -249,34 +235,24 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +261,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}'} # 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 + **kwargs: Any ) -> "_models.Runbook": """Create the runbook identified by runbook name. @@ -316,39 +295,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +330,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}/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 + **kwargs: Any ) -> "_models.Runbook": """Update the runbook identified by runbook name. @@ -391,39 +363,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +394,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the runbook by name. @@ -459,34 +424,24 @@ async def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -494,11 +449,13 @@ async def delete( 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 + **kwargs: Any ) -> AsyncIterable["_models.RunbookListResult"]: """Retrieve a list of runbooks. @@ -508,7 +465,8 @@ def list_by_automation_account( :type automation_account_name: 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"] @@ -516,36 +474,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -558,12 +513,13 @@ async def get_next(next_link=None): 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 ) 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 a23002841dcb2..68f155604f711 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, schedule_name: str, parameters: "_models.ScheduleCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> Optional["_models.Schedule"]: """Create a schedule. @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +111,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}/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 + **kwargs: Any ) -> "_models.Schedule": """Update the schedule identified by schedule name. @@ -145,39 +144,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +175,17 @@ 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 + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, schedule_name: str, - **kwargs + **kwargs: Any ) -> "_models.Schedule": """Retrieve the schedule identified by schedule name. @@ -213,34 +205,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +231,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, schedule_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the schedule identified by schedule name. @@ -276,34 +261,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -311,11 +286,13 @@ async def delete( 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 + **kwargs: Any ) -> AsyncIterable["_models.ScheduleListResult"]: """Retrieve a list of schedules. @@ -325,7 +302,8 @@ def list_by_automation_account( :type automation_account_name: 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"] @@ -333,36 +311,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -375,12 +350,13 @@ async def get_next(next_link=None): 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 ) 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 3ca0dfd2d7d87..be0cea20e7bd0 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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 + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationMachineRun": """Get a single software update configuration machine run by Id. @@ -69,36 +74,25 @@ async def get_by_id( 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 = 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, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +101,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 + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -117,7 +114,7 @@ async def list( filter: Optional[str] = None, skip: Optional[str] = None, top: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationMachineRunListResult": """Return list of software update configuration machine runs. @@ -145,41 +142,27 @@ async def list( 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) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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 +171,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 + 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 ae3084d092356..d3b1c03102eb2 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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 + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationRun": """Get a single software update configuration Run by Id. @@ -68,36 +73,25 @@ async def get_by_id( 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 = 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, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +100,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 + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -116,7 +113,7 @@ async def list( filter: Optional[str] = None, skip: Optional[str] = None, top: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationRunListResult": """Return list of software update configuration runs. @@ -144,41 +141,27 @@ async def list( 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) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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 +170,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 + 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 5ef8f8af42b38..f3655b2eb8589 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, @@ -47,7 +52,7 @@ async def create( software_update_configuration_name: str, parameters: "_models.SoftwareUpdateConfiguration", client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.SoftwareUpdateConfiguration": """Create a new software update configuration with the name given in the URI. @@ -72,41 +77,30 @@ async def create( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,15 +113,18 @@ 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 + + @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 + **kwargs: Any ) -> "_models.SoftwareUpdateConfiguration": """Get a single software update configuration by name. @@ -150,36 +147,25 @@ async def get_by_name( 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 = 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, + client_request_id=client_request_id, + template_url=self.get_by_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +174,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 + + @distributed_trace_async async def delete( 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. @@ -219,36 +208,25 @@ async def delete( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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, + client_request_id=client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -256,13 +234,15 @@ async def delete( 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 + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationListResult": """Get all software update configurations for the account. @@ -284,37 +264,25 @@ async def list( 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 = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +291,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 + 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 c23577932dfe2..5c4aa8b2c7081 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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 + **kwargs: Any ) -> "_models.SourceControl": """Create a source control. @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +110,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}/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 + **kwargs: Any ) -> "_models.SourceControl": """Update a source control. @@ -144,39 +143,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +174,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, source_control_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the source control. @@ -212,34 +204,24 @@ async def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -247,12 +229,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.SourceControl": """Retrieve the source control identified by source control name. @@ -272,34 +256,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,14 +282,17 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SourceControlListResult"]: """Retrieve a list of source controls. @@ -326,8 +303,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -335,38 +314,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -379,12 +355,13 @@ async def get_next(next_link=None): 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 ) 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 43a6647ef3a32..7616e111dd724 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, @@ -48,7 +54,7 @@ async def create( source_control_name: str, source_control_sync_job_id: str, parameters: "_models.SourceControlSyncJobCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.SourceControlSyncJob": """Creates the sync job for a source control. @@ -72,40 +78,30 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +110,18 @@ 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 + + @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 + **kwargs: Any ) -> "_models.SourceControlSyncJobById": """Retrieve the source control sync job identified by job id. @@ -144,35 +143,25 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +170,18 @@ 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 + + @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 + **kwargs: Any ) -> AsyncIterable["_models.SourceControlSyncJobListResult"]: """Retrieve a list of source control sync jobs. @@ -202,8 +194,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -211,39 +205,37 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -256,12 +248,13 @@ async def get_next(next_link=None): 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 ) 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 ca50b6f067f3e..825cbb8e0a53a 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sync_job( self, resource_group_name: str, @@ -48,7 +54,7 @@ def list_by_sync_job( source_control_name: str, source_control_sync_job_id: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SourceControlSyncJobStreamsListBySyncJob"]: """Retrieve a list of sync job streams identified by sync job id. @@ -63,8 +69,10 @@ def list_by_sync_job( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -72,40 +80,39 @@ def list_by_sync_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -118,17 +125,19 @@ async def get_next(next_link=None): 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 + @distributed_trace_async async def get( self, resource_group_name: str, @@ -136,7 +145,7 @@ async def get( source_control_name: str, source_control_sync_job_id: str, stream_id: str, - **kwargs + **kwargs: Any ) -> "_models.SourceControlSyncJobStreamById": """Retrieve a sync job stream identified by stream id. @@ -160,36 +169,26 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +197,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 + 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 2a4fe0ae52da3..11f1eccfaa3a6 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.StatisticsListResult"]: """Retrieve the statistics for the account. @@ -57,8 +63,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -66,38 +74,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -110,12 +115,13 @@ async def get_next(next_link=None): 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 ) 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 ea440aad64979..fc29015a0a415 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, automation_account_name: str, runbook_name: str, parameters: "_models.TestJobCreateParameters", - **kwargs + **kwargs: Any ) -> "_models.TestJob": """Create a test job of the runbook. @@ -68,39 +73,29 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TestJobCreateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +104,17 @@ 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 + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> "_models.TestJob": """Retrieve the test job for the specified runbook. @@ -136,34 +134,24 @@ async def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +160,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 + + @distributed_trace_async async def resume( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the test job. @@ -199,34 +190,24 @@ async def resume( 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) - - # 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 = 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, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -234,12 +215,14 @@ async def resume( resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + + @distributed_trace_async async def stop( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Stop the test job. @@ -259,34 +242,24 @@ async def stop( 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) - - # 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 = 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, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -294,12 +267,14 @@ async def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + + @distributed_trace_async async def suspend( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Suspend the test job. @@ -319,37 +294,28 @@ async def suspend( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 + 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 55fb84a09c427..817cfb8e77d0f 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, job_stream_id: str, - **kwargs + **kwargs: Any ) -> "_models.JobStream": """Retrieve a test job stream of the test job identified by runbook name and stream id. @@ -69,35 +75,25 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +102,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/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 + **kwargs: Any ) -> AsyncIterable["_models.JobStreamListResult"]: """Retrieve a list of test job streams identified by runbook name. @@ -128,7 +127,8 @@ def list_by_test_job( :type filter: 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"] @@ -136,39 +136,37 @@ def list_by_test_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -181,12 +179,13 @@ async def get_next(next_link=None): 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 ) 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 99ddccc83f142..51ccb9b819e93 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.UsageListResult"]: """Retrieve the usage for the account id. @@ -63,36 +69,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -105,12 +108,13 @@ async def get_next(next_link=None): 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 ) 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 b2d88278a5d95..743484a708d28 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, variable_name: str, parameters: "_models.VariableCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Variable": """Create a variable. @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +110,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}/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 + **kwargs: Any ) -> "_models.Variable": """Update a variable. @@ -144,39 +143,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +174,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, variable_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the variable. @@ -212,34 +204,24 @@ async def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -247,12 +229,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Variable": """Retrieve the variable identified by variable name. @@ -272,34 +256,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,13 +282,16 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.VariableListResult"]: """Retrieve a list of variables. @@ -324,7 +301,8 @@ def list_by_automation_account( :type automation_account_name: 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"] @@ -332,36 +310,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -374,12 +349,13 @@ async def get_next(next_link=None): 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 ) 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 84c360c06ddc0..cb0e840907f90 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, watcher_name: str, parameters: "_models.Watcher", - **kwargs + **kwargs: Any ) -> "_models.Watcher": """Create the watcher identified by watcher name. @@ -69,39 +75,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +110,17 @@ 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 + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> "_models.Watcher": """Retrieve the watcher identified by watcher name. @@ -141,34 +140,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +166,18 @@ 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 + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, watcher_name: str, parameters: "_models.WatcherUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Watcher": """Update the watcher identified by watcher name. @@ -207,39 +199,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +230,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the watcher by name. @@ -275,34 +260,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -310,12 +285,14 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + + @distributed_trace_async async def start( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -335,34 +312,24 @@ async def start( 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) - - # 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 = 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, + template_url=self.start.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -370,12 +337,14 @@ async def start( start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + + @distributed_trace_async async def stop( self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -395,34 +364,24 @@ async def stop( 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) - - # 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 = 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, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -430,12 +389,14 @@ async def stop( 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 + **kwargs: Any ) -> AsyncIterable["_models.WatcherListResult"]: """Retrieve a list of watchers. @@ -447,7 +408,8 @@ def list_by_automation_account( :type filter: 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"] @@ -455,38 +417,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -499,12 +458,13 @@ async def get_next(next_link=None): 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 ) 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 8c7cfe5208a20..51a4741005ef0 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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. @@ -63,33 +69,23 @@ async def generate_uri( 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) - # 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 = build_generate_uri_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.generate_uri.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 +94,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 + + @distributed_trace_async async def delete( self, resource_group_name: str, automation_account_name: str, webhook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the webhook by name. @@ -125,34 +124,24 @@ async def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -160,12 +149,14 @@ async def delete( 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 + **kwargs: Any ) -> "_models.Webhook": """Retrieve the webhook identified by webhook name. @@ -185,34 +176,24 @@ async def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,15 +202,18 @@ 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, webhook_name: str, parameters: "_models.WebhookCreateOrUpdateParameters", - **kwargs + **kwargs: Any ) -> "_models.Webhook": """Create the webhook identified by webhook name. @@ -251,39 +235,29 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +270,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}/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 + **kwargs: Any ) -> "_models.Webhook": """Update the webhook identified by webhook name. @@ -326,39 +303,29 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'WebhookUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,14 +334,17 @@ 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 + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.WebhookListResult"]: """Retrieve a list of webhooks. @@ -386,7 +356,8 @@ def list_by_automation_account( :type filter: 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"] @@ -394,38 +365,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -438,12 +406,13 @@ async def get_next(next_link=None): 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 ) 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 39d1b340a56fc..c86e82de17eb0 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,6 +220,7 @@ TagOperators, TokenType, WindowsUpdateClasses, + WorkerType, ) __all__ = [ @@ -382,6 +244,7 @@ 'CertificateCreateOrUpdateParameters', 'CertificateListResult', 'CertificateUpdateParameters', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'Connection', 'ConnectionCreateOrUpdateParameters', 'ConnectionListResult', @@ -420,12 +283,21 @@ 'DscReportError', 'DscReportResource', 'DscReportResourceNavigation', + 'EncryptionProperties', + 'EncryptionPropertiesIdentity', 'ErrorResponse', 'FieldDefinition', + 'GraphicalRunbookContent', 'HybridRunbookWorker', + 'HybridRunbookWorkerCreateParameters', 'HybridRunbookWorkerGroup', + 'HybridRunbookWorkerGroupCreateOrUpdateParameters', 'HybridRunbookWorkerGroupUpdateParameters', 'HybridRunbookWorkerGroupsListResult', + 'HybridRunbookWorkerLegacy', + 'HybridRunbookWorkerMoveParameters', + 'HybridRunbookWorkersListResult', + 'Identity', 'Job', 'JobCollectionItem', 'JobCreateParameters', @@ -438,6 +310,7 @@ 'JobStreamListResult', 'Key', 'KeyListResult', + 'KeyVaultProperties', 'LinkedWorkspace', 'LinuxProperties', 'Module', @@ -452,9 +325,16 @@ 'Operation', 'OperationDisplay', 'OperationListResult', + 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', + 'PrivateEndpointProperty', + 'PrivateLinkResource', + 'PrivateLinkResourceListResult', + 'PrivateLinkServiceConnectionStateProperty', 'ProxyResource', 'PythonPackageCreateParameters', 'PythonPackageUpdateParameters', + 'RawGraphicalRunbookContent', 'Resource', 'RunAsCredentialAssociationProperty', 'Runbook', @@ -498,6 +378,7 @@ 'SourceControlUpdateParameters', 'Statistics', 'StatisticsListResult', + 'SystemData', 'TagSettingsProperties', 'TargetProperties', 'TaskProperties', @@ -529,7 +410,10 @@ 'AutomationKeyPermissions', 'ContentSourceType', 'CountType', + 'CreatedByType', 'DscConfigurationState', + 'EncryptionKeySourceType', + 'GraphRunbookType', 'GroupTypeEnum', 'HttpStatusCode', 'JobProvisioningState', @@ -539,6 +423,7 @@ 'ModuleProvisioningState', 'OperatingSystemType', 'ProvisioningState', + 'ResourceIdentityType', 'RunbookState', 'RunbookTypeEnum', 'ScheduleDay', @@ -550,4 +435,5 @@ 'TagOperators', 'TokenType', 'WindowsUpdateClasses', + 'WorkerType', ] 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 2308a221239d3..a3f77b0da40ca 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,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -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)): +class AgentRegistrationKeyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the agent registration key name - primary or secondary. """ PRIMARY = "primary" SECONDARY = "secondary" -class AutomationAccountState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationAccountState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets status of account. """ @@ -41,33 +26,42 @@ class AutomationAccountState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) UNAVAILABLE = "Unavailable" SUSPENDED = "Suspended" -class AutomationKeyName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationKeyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automation key name. """ PRIMARY = "Primary" SECONDARY = "Secondary" -class AutomationKeyPermissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutomationKeyPermissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Automation key permissions. """ READ = "Read" FULL = "Full" -class ContentSourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ContentSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the content source type. """ EMBEDDED_CONTENT = "embeddedContent" URI = "uri" -class CountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STATUS = "status" NODECONFIGURATION = "nodeconfiguration" -class DscConfigurationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DscConfigurationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the state of the configuration. """ @@ -75,14 +69,28 @@ class DscConfigurationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) EDIT = "Edit" PUBLISHED = "Published" -class GroupTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionKeySourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Encryption Key Source + """ + + MICROSOFT_AUTOMATION = "Microsoft.Automation" + MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + +class GraphRunbookType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Runbook Type + """ + + GRAPH_POWER_SHELL = "GraphPowerShell" + GRAPH_POWER_SHELL_WORKFLOW = "GraphPowerShellWorkflow" + +class GroupTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the HybridWorkerGroup. """ USER = "User" SYSTEM = "System" -class HttpStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CONTINUE_ENUM = "Continue" SWITCHING_PROTOCOLS = "SwitchingProtocols" @@ -132,7 +140,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the resource. """ @@ -141,7 +149,7 @@ class JobProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUSPENDED = "Suspended" PROCESSING = "Processing" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the status of the job. """ @@ -159,7 +167,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESUMING = "Resuming" REMOVING = "Removing" -class JobStreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStreamType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the stream type. """ @@ -171,7 +179,7 @@ class JobStreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VERBOSE = "Verbose" ANY = "Any" -class LinuxUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LinuxUpdateClasses(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Update classifications included in the software update configuration. """ @@ -180,7 +188,7 @@ class LinuxUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SECURITY = "Security" OTHER = "Other" -class ModuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ModuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the provisioning state of the module. """ @@ -201,14 +209,14 @@ class ModuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum CANCELLED = "Cancelled" UPDATING = "Updating" -class OperatingSystemType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Target operating system for the software update configuration. """ WINDOWS = "Windows" LINUX = "Linux" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the job. """ @@ -216,7 +224,16 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" RUNNING = "Running" -class RunbookState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + +class RunbookState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the state of the runbook. """ @@ -224,7 +241,7 @@ class RunbookState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EDIT = "Edit" PUBLISHED = "Published" -class RunbookTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RunbookTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the type of the runbook. """ @@ -235,7 +252,7 @@ class RunbookTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GRAPH_POWER_SHELL_WORKFLOW = "GraphPowerShellWorkflow" GRAPH_POWER_SHELL = "GraphPowerShell" -class ScheduleDay(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScheduleDay(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. """ @@ -248,7 +265,7 @@ class ScheduleDay(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SATURDAY = "Saturday" SUNDAY = "Sunday" -class ScheduleFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScheduleFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the frequency of the schedule. """ @@ -257,16 +274,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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the SKU name of the account. """ FREE = "Free" BASIC = "Basic" -class SourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source type. Must be one of VsoGit, VsoTfvc, GitHub. """ @@ -274,35 +292,35 @@ class SourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VSO_TFVC = "VsoTfvc" GIT_HUB = "GitHub" -class StreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StreamType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the sync job stream. """ ERROR = "Error" OUTPUT = "Output" -class SyncType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SyncType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The sync type. """ PARTIAL_SYNC = "PartialSync" FULL_SYNC = "FullSync" -class TagOperators(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagOperators(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Filter VMs by Any or All specified tags. """ ALL = "All" ANY = "Any" -class TokenType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TokenType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The token type. Must be either PersonalAccessToken or Oauth. """ PERSONAL_ACCESS_TOKEN = "PersonalAccessToken" OAUTH = "Oauth" -class WindowsUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class WindowsUpdateClasses(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Update classification included in the software update configuration. A comma separated string with required values """ @@ -316,3 +334,10 @@ class WindowsUpdateClasses(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEFINITION = "Definition" TOOLS = "Tools" UPDATES = "Updates" + +class WorkerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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 aac6ffa75c5f7..0000000000000 --- 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 7fbb522912f4b..fafe3f9733740 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,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -20,22 +20,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 = { @@ -65,6 +65,22 @@ def __init__( 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 +95,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 = { @@ -97,6 +113,12 @@ def __init__( 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 +127,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 +145,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 +159,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 = { @@ -192,6 +219,39 @@ def __init__( validation_set: Optional[List["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 +268,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 = { @@ -226,6 +286,12 @@ def __init__( parameters: Optional[List["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 +300,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 +314,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 +325,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] """ @@ -278,6 +348,16 @@ def __init__( monthly_occurrences: Optional[List["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 +367,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, + :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. Possible values include: "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday". - :type day: str or ~azure.mgmt.automation.models.ScheduleDay + :vartype day: str or ~azure.mgmt.automation.models.ScheduleDay """ _attribute_map = { @@ -307,6 +387,14 @@ def __init__( day: Optional[Union[str, "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. Possible values include: "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 +403,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 = { @@ -341,6 +429,16 @@ def __init__( 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 +449,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 +467,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 +483,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. + :ivar 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 + :vartype key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName """ _validation = { @@ -398,6 +502,11 @@ def __init__( key_name: Union[str, "AgentRegistrationKeyName"], **kwargs ): + """ + :keyword key_name: Required. Gets or sets the agent registration key name - primary or + secondary. Possible values include: "primary", "secondary". + :paramtype key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName + """ super(AgentRegistrationRegenerateKeyParameter, self).__init__(**kwargs) self.key_name = key_name @@ -431,6 +540,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -448,10 +559,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 +586,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 +608,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 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. 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 + :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 +663,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 +684,96 @@ def __init__( tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, etag: Optional[str] = None, + identity: Optional["Identity"] = None, sku: Optional["Sku"] = None, last_modified_by: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + encryption: Optional["EncryptionProperties"] = None, + private_endpoint_connections: Optional[List["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 +781,52 @@ def __init__( *, name: Optional[str] = None, location: Optional[str] = None, + identity: Optional["Identity"] = None, tags: Optional[Dict[str, str]] = None, sku: Optional["Sku"] = None, - **kwargs - ): + encryption: Optional["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 = { @@ -613,6 +841,12 @@ def __init__( 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 +855,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 +890,54 @@ def __init__( *, name: Optional[str] = None, location: Optional[str] = None, + identity: Optional["Identity"] = None, tags: Optional[Dict[str, str]] = None, sku: Optional["Sku"] = None, - **kwargs - ): + encryption: Optional["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 = { @@ -679,13 +954,55 @@ def __init__( tag_settings: Optional["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 +1023,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 +1056,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 +1074,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 +1109,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 +1132,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 = { @@ -817,6 +1150,12 @@ def __init__( 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 +1164,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 +1182,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 +1236,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 = { @@ -898,6 +1275,12 @@ def __init__( 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 +1294,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 = { @@ -942,6 +1325,17 @@ def __init__( 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 +1346,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 = { @@ -970,6 +1364,12 @@ def __init__( 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 +1386,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 +1425,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 +1447,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 +1461,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 +1474,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 = { @@ -1089,6 +1501,15 @@ def __init__( 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 +1519,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 = { @@ -1116,6 +1537,12 @@ def __init__( 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 +1551,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 +1573,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 +1592,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 +1615,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 +1629,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 = { @@ -1210,6 +1651,14 @@ def __init__( 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 +1668,15 @@ 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", + :ivar hash: Gets or sets the hash. + :vartype hash: ~azure.mgmt.automation.models.ContentHash + :ivar 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 + :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 = { @@ -1246,6 +1695,18 @@ def __init__( 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. Possible values include: + "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 +1714,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 +1731,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 +1760,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 +1776,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 +1808,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 +1828,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 = { @@ -1371,6 +1846,12 @@ def __init__( 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 +1860,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 +1886,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 +1903,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 +1914,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. 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 + :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. 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 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 +1944,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 = { @@ -1502,6 +1993,24 @@ def __init__( 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. Possible values + include: "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. Possible values include: "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 +2033,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 = { @@ -1563,6 +2072,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 +2099,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 = { @@ -1593,6 +2117,12 @@ def __init__( 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 +2139,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", + :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. 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 + :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,14 +2194,13 @@ 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, @@ -1684,8 +2212,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. Possible values include: "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 +2259,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 +2273,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 +2286,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 = { @@ -1769,6 +2332,24 @@ def __init__( 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 +2364,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 = { @@ -1805,6 +2386,14 @@ def __init__( 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 +2403,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 +2430,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 +2451,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 = { @@ -1889,6 +2489,22 @@ def __init__( 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 +2518,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 +2560,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 +2592,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 +2603,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 = { @@ -2026,6 +2664,30 @@ def __init__( 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 +2701,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 +2712,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 = { @@ -2094,6 +2756,21 @@ def __init__( 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 +2783,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 = { @@ -2137,6 +2814,19 @@ def __init__( 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 +2838,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 = { @@ -2170,6 +2860,14 @@ def __init__( 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 +2877,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 +2895,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 +2909,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 = { @@ -2227,6 +2931,14 @@ def __init__( 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 +2948,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 = { @@ -2323,6 +3035,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 +3101,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 = { @@ -2366,6 +3119,12 @@ def __init__( 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 +3133,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 = { @@ -2392,6 +3151,12 @@ def __init__( properties: Optional["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 +3165,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 +3179,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 +3190,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 +3224,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 +3250,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 = { @@ -2518,6 +3301,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 +3340,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 +3354,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. Possible values include: "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["KeyVaultProperties"] = None, + key_source: Optional[Union[str, "EncryptionKeySourceType"]] = None, + identity: Optional["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. Possible values include: "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 +3453,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 +3469,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 +3495,201 @@ 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["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. Possible values include: "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, "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. Possible values include: "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. Possible values include: "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, + hybrid_runbook_workers: Optional[List["HybridRunbookWorkerLegacy"]] = None, credential: Optional["RunAsCredentialAssociationProperty"] = None, group_type: Optional[Union[str, "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. Possible values include: "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["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 = { @@ -2713,6 +3771,12 @@ def __init__( 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 = { @@ -2735,11 +3799,173 @@ def __init__( credential: Optional["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["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. Possible values include: "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, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Possible values include: "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. 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 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. Possible values include: "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 = { @@ -2829,6 +4055,40 @@ def __init__( provisioning_state: Optional[Union[str, "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. Possible values include: "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. Possible values + include: "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. @@ -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 = { @@ -2952,6 +4216,15 @@ def __init__( 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 """ @@ -2984,6 +4257,10 @@ def __init__( value: Optional[List["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 = { @@ -3064,6 +4343,18 @@ def __init__( 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 = { @@ -3111,6 +4402,16 @@ def __init__( 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 = { @@ -3139,6 +4440,12 @@ def __init__( 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. Possible values include: "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 = { @@ -3183,9 +4490,26 @@ def __init__( stream_type: Optional[Union[str, "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. Possible values include: "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 = { @@ -3217,6 +4541,12 @@ def __init__( 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 @@ -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 = { @@ -3274,10 +4606,53 @@ def __init__( keys: Optional[List["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 + :ivar 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 + :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 = { @@ -3333,6 +4711,18 @@ def __init__( reboot_setting: Optional[str] = None, **kwargs ): + """ + :keyword included_package_classifications: Update classifications included in the software + update configuration. Possible values include: "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 + :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. 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 + :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 = { @@ -3430,6 +4820,40 @@ def __init__( 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. Possible values + include: "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 = { @@ -3480,6 +4904,16 @@ def __init__( 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 = { @@ -3534,6 +4974,12 @@ def __init__( 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 = { @@ -3568,6 +5014,16 @@ def __init__( content_link: Optional["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 = { @@ -3596,6 +5052,12 @@ def __init__( properties: Optional["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 = { @@ -3643,6 +5109,12 @@ def __init__( 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 = { @@ -3695,6 +5173,12 @@ def __init__( display: Optional["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 = { @@ -3748,12 +5240,16 @@ def __init__( value: Optional[List["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,12 @@ 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 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 +5277,190 @@ 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'}, + 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, } def __init__( self, + *, + private_endpoint: Optional["PrivateEndpointProperty"] = None, + private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.automation.models.PrivateEndpointProperty + :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.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["PrivateEndpointConnection"]] = None, + **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["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 +5468,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 = { @@ -3811,6 +5490,12 @@ 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] + :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 +5504,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 +5518,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. Possible values include: "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, "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. Possible values include: "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 +5584,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 +5603,51 @@ 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", + :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. 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", + :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. 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 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,8 +5674,6 @@ class Runbook(TrackedResource): 'description': {'key': 'properties.description', 'type': 'str'}, } - provisioning_state = "Succeeded" - def __init__( self, *, @@ -3959,12 +5690,54 @@ def __init__( parameters: Optional[Dict[str, "RunbookParameter"]] = None, output_types: Optional[List[str]] = None, draft: Optional["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. Possible values include: "Script", + "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell". + :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. Possible values include: "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 +5750,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 +5760,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 +5774,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 +5787,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 +5805,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 +5818,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: + :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. 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 + :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 = { @@ -4077,6 +5859,22 @@ def __init__( 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. Possible values include: + "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", + "GraphPowerShell". + :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 +5889,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: + :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. 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 + :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 = { @@ -4147,6 +5945,30 @@ 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 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. Possible values include: + "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", + "GraphPowerShell". + :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 +5985,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 = { @@ -4197,6 +6019,20 @@ def __init__( 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 +6045,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: 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 + :vartype status_code: str or ~azure.mgmt.automation.models.HttpStatusCode + :ivar request_id: + :vartype request_id: str """ _attribute_map = { @@ -4237,6 +6072,22 @@ def __init__( request_id: Optional[str] = None, **kwargs ): + """ + :keyword 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". + :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 +6096,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 = { @@ -4263,6 +6114,12 @@ def __init__( 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 +6128,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 +6155,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 +6176,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 +6214,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 +6240,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 +6251,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: + :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. 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 + :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,7 +6318,7 @@ def __init__( is_enabled: Optional[bool] = False, next_run: Optional[datetime.datetime] = None, next_run_offset_minutes: Optional[float] = None, - interval: Optional[object] = None, + interval: Optional[Any] = None, frequency: Optional[Union[str, "ScheduleFrequency"]] = None, time_zone: Optional[str] = None, advanced_schedule: Optional["AdvancedSchedule"] = None, @@ -4443,6 +6327,35 @@ def __init__( 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. Possible values include: + "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 +6376,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 +6390,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 +6403,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. Possible values include: + "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 = { @@ -4530,11 +6447,30 @@ def __init__( frequency: Union[str, "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 ): + """ + :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. Possible values + include: "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 +6485,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 = { @@ -4567,6 +6503,12 @@ def __init__( 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 +6517,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 +6539,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 +6558,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: + :ivar 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 + :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 = { @@ -4635,6 +6585,15 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Gets or sets the SKU name of the account. Possible values include: + "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 +6613,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 +6631,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 = { @@ -4713,6 +6672,17 @@ def __init__( tasks: Optional["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 +6707,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 + :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. 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 + :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 +6725,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 = { @@ -4790,6 +6760,19 @@ def __init__( 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. Possible values include: "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 +6789,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 = { @@ -4820,6 +6803,10 @@ def __init__( value: Optional[List["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 +6824,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 +6841,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 +6851,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 = { @@ -4915,6 +6902,15 @@ def __init__( error: Optional["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 +6935,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 = { @@ -4958,6 +6953,13 @@ def __init__( 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 +6974,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 +6999,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 = { @@ -5042,6 +7044,13 @@ def __init__( tasks: Optional["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 +7072,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 = { @@ -5081,6 +7090,12 @@ def __init__( 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 +7104,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 +7126,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 +7143,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 = { @@ -5138,6 +7161,13 @@ def __init__( post_task: Optional["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 +7176,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 = { @@ -5164,12 +7194,18 @@ def __init__( post_task: Optional["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 +7216,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 + :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. 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 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 = { @@ -5237,6 +7273,28 @@ def __init__( 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. Possible values + include: "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 +7310,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. + :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. 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 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 = { @@ -5303,6 +7361,26 @@ def __init__( 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. + Possible values include: "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 +7395,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 = { @@ -5335,6 +7413,12 @@ def __init__( 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 +7427,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 + :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. Possible values include: "PersonalAccessToken", "Oauth". - :type token_type: str or ~azure.mgmt.automation.models.TokenType + :vartype token_type: str or ~azure.mgmt.automation.models.TokenType """ _validation = { @@ -5371,6 +7455,15 @@ def __init__( token_type: Optional[Union[str, "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. Possible + values include: "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 +7481,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: + :ivar provisioning_state: The provisioning state of the job. Possible values include: "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :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. Possible values include: "PartialSync", "FullSync". + :vartype sync_type: str or ~azure.mgmt.automation.models.SyncType """ _validation = { @@ -5432,6 +7525,15 @@ def __init__( sync_type: Optional[Union[str, "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. Possible values include: + "Completed", "Failed", "Running". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :keyword sync_type: The sync type. Possible values include: "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 +7551,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: + :ivar provisioning_state: The provisioning state of the job. Possible values include: "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :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. Possible values include: "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 = { @@ -5495,6 +7597,19 @@ def __init__( 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. Possible values include: + "Completed", "Failed", "Running". + :paramtype provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState + :keyword sync_type: The sync type. Possible values include: "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 +7626,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 +7645,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 +7657,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 = { @@ -5555,6 +7675,12 @@ def __init__( 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 +7693,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. Possible values include: "Error", "Output". + :vartype stream_type: str or ~azure.mgmt.automation.models.StreamType """ _validation = { @@ -5599,6 +7724,15 @@ def __init__( stream_type: Optional[Union[str, "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. Possible values include: "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 +7748,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. Possible values include: "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 = { @@ -5651,9 +7784,22 @@ def __init__( summary: Optional[str] = None, stream_type: Optional[Union[str, "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. Possible values include: "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 +7815,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 """ @@ -5690,6 +7836,10 @@ def __init__( value: Optional[List["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 +7848,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 = { @@ -5732,6 +7882,20 @@ def __init__( 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 +7942,8 @@ def __init__( self, **kwargs ): + """ + """ super(Statistics, self).__init__(**kwargs) self.counter_property = None self.counter_value = None @@ -5789,8 +7955,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 = { @@ -5803,6 +7969,10 @@ def __init__( value: Optional[List["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 +7982,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: + :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. 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 + :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 = { @@ -5882,6 +8052,35 @@ def __init__( 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. Possible values include: + "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 +8098,78 @@ 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. Possible values include: + "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. Possible + values include: "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, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "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. Possible values + include: "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. Possible + values include: "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. Possible values include: "All", + "Any". + :vartype filter_operator: str or ~azure.mgmt.automation.models.TagOperators """ _attribute_map = { @@ -5921,6 +8184,13 @@ def __init__( filter_operator: Optional[Union[str, "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. Possible values include: + "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 +8199,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 = { @@ -5947,6 +8217,12 @@ def __init__( non_azure_queries: Optional[List["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 +8231,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 +8249,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 +8263,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 +8318,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 +8360,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 +8379,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 +8394,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 +8412,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 +8426,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 = { @@ -6120,6 +8440,10 @@ def __init__( value: Optional[List["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 +8453,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. Possible values include: + "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 = { @@ -6175,6 +8499,26 @@ def __init__( targets: Optional["TargetProperties"] = None, **kwargs ): + """ + :keyword operating_system: Required. operating system of target machines. Possible values + include: "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 +8551,8 @@ def __init__( self, **kwargs ): + """ + """ super(UpdateConfigurationNavigation, self).__init__(**kwargs) self.name = None @@ -6214,18 +8560,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 = { @@ -6248,6 +8594,20 @@ def __init__( 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 +8620,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 +8638,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 +8652,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 = { @@ -6300,11 +8666,15 @@ def __init__( value: Optional[List["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 +8685,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 +8724,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 +8749,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 +8779,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 +8799,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 = { @@ -6425,6 +8817,12 @@ def __init__( 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 +8831,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 +8853,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 +8878,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 +8902,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 +8947,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 +8986,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 = { @@ -6577,6 +9004,12 @@ def __init__( 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 +9018,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 +9037,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 +9060,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 = { @@ -6684,6 +9124,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 +9168,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 = { @@ -6745,6 +9210,22 @@ def __init__( 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 +9239,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 = { @@ -6776,6 +9257,12 @@ def __init__( 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 +9271,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 +9301,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 +9324,18 @@ def __init__( class WindowsProperties(msrest.serialization.Model): """Windows specific update configuration. - :param included_update_classifications: Update classification included in the software update + :ivar 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 + :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 = { @@ -6855,6 +9354,20 @@ def __init__( 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. Possible values include: + "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/operations/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py index d7371312a9c81..23136da95dd4b 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,38 @@ 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 __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 +74,6 @@ 'ConnectionOperations', 'ConnectionTypeOperations', 'CredentialOperations', - 'DscConfigurationOperations', - 'SoftwareUpdateConfigurationsOperations', 'HybridRunbookWorkerGroupOperations', 'JobScheduleOperations', 'LinkedWorkspaceOperations', @@ -85,9 +81,21 @@ 'ModuleOperations', 'ObjectDataTypesOperations', 'FieldsOperations', - 'Operations', 'ScheduleOperations', 'VariableOperations', 'WatcherOperations', + 'DscConfigurationOperations', + 'JobOperations', + 'JobStreamOperations', + 'Operations', + 'AutomationClientOperationsMixin', + 'SoftwareUpdateConfigurationsOperations', + 'SoftwareUpdateConfigurationRunsOperations', + 'SoftwareUpdateConfigurationMachineRunsOperations', + 'RunbookDraftOperations', + 'RunbookOperations', + 'TestJobStreamsOperations', + 'TestJobOperations', 'WebhookOperations', + 'HybridRunbookWorkersOperations', ] 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 b0fade70343f2..08931231231aa 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 @@ -5,23 +5,101 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + activity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_module_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ActivityOperations(object): """ActivityOperations operations. @@ -45,15 +123,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,35 +152,25 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +179,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 + + @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. @@ -139,37 +209,35 @@ def list_by_module( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_module.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -182,12 +250,13 @@ def get_next(next_link=None): 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 ) 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 8424b6318383c..ac10760d91026 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 @@ -5,22 +5,104 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_key_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AgentRegistrationInformationOperations(object): """AgentRegistrationInformationOperations operations. @@ -44,13 +126,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -67,33 +149,23 @@ def get( 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') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +174,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 + + @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. @@ -130,38 +204,28 @@ def regenerate_key( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - # 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') + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +234,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 + 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 e1f427427c47e..529da3b350c2d 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 @@ -5,23 +5,248 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-06-22" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AutomationAccountOperations(object): """AutomationAccountOperations operations. @@ -45,14 +270,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -71,38 +296,28 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') - # 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') + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +326,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -139,38 +356,28 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +390,17 @@ 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 + + @distributed_trace def delete( 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. @@ -208,33 +417,23 @@ def delete( 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) - - # 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 = build_delete_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -242,13 +441,14 @@ def delete( 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. @@ -265,33 +465,23 @@ def get( 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 = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,20 +490,23 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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 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 """ @@ -322,35 +515,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -363,28 +552,30 @@ def get_next(next_link=None): 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 + @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 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 """ @@ -393,34 +584,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -433,12 +619,13 @@ def get_next(next_link=None): 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 ) 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 0000000000000..1e546e619237d --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py @@ -0,0 +1,132 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class AutomationClientOperationsMixin(object): + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GraphicalRunbookContent"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.convert_graph_runbook_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 9387b3b3e4697..632d0f0691df3 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CertificateOperations(object): """CertificateOperations operations. @@ -45,14 +249,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +275,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +300,15 @@ def delete( 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. @@ -132,34 +327,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,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 + + @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. @@ -199,39 +386,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +421,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 + + @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. @@ -275,39 +454,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +485,17 @@ 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 + + @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. @@ -332,7 +503,8 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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 """ @@ -341,36 +513,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -383,12 +552,13 @@ def get_next(next_link=None): 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 ) 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 cb6d8fd83ae7d..0b7603a7fbb66 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ConnectionOperations(object): """ConnectionOperations operations. @@ -45,14 +249,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +275,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +300,15 @@ def delete( 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. @@ -132,34 +327,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,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 + + @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. @@ -199,39 +386,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +421,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 + + @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. @@ -275,39 +454,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +485,17 @@ 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 + + @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. @@ -332,7 +503,8 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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 """ @@ -341,36 +513,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -383,12 +552,13 @@ def get_next(next_link=None): 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 ) 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 51e8e25f5b378..887a3fc8427a1 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 @@ -5,23 +5,181 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ConnectionTypeOperations(object): """ConnectionTypeOperations operations. @@ -45,14 +203,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +229,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +254,15 @@ def delete( 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. @@ -132,34 +281,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +307,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 + + @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. @@ -200,39 +341,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +372,17 @@ 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 + + @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. @@ -257,7 +390,8 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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 """ @@ -266,36 +400,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -308,12 +439,13 @@ def get_next(next_link=None): 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 ) 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 46682979714b4..018aea0bfa376 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + credential_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CredentialOperations(object): """CredentialOperations operations. @@ -45,14 +249,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +275,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +300,15 @@ def delete( 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. @@ -132,34 +327,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,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 + + @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. @@ -199,39 +386,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +421,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 + + @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. @@ -275,39 +454,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +485,17 @@ 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 + + @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. @@ -332,7 +503,8 @@ def list_by_automation_account( :param automation_account_name: The name of the automation account. :type automation_account_name: 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 """ @@ -341,36 +513,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -388,6 +557,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) 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 753e49c664b70..770b4d35d3b24 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 @@ -5,25 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DscCompilationJobOperations(object): """DscCompilationJobOperations operations. @@ -49,52 +213,40 @@ def __init__(self, client, config, serializer, 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" + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + parameters: "_models.DscCompilationJobCreateParameters", + **kwargs: Any + ) -> "_models.DscCompilationJob": 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" - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +254,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 + + @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. @@ -125,15 +279,19 @@ def begin_create( :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( 'polling_interval', @@ -146,28 +304,21 @@ def begin_create( automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -179,16 +330,17 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -207,34 +359,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,16 +385,18 @@ 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 + + @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. @@ -262,7 +406,8 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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 """ @@ -271,38 +416,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -315,26 +457,27 @@ def get_next(next_link=None): 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 + @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. @@ -355,35 +498,25 @@ def get_stream( 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') + + 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, + template_url=self.get_stream.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +525,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 + 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 1726272bfbda5..5f34eb8487d26 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 @@ -5,22 +5,61 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DscCompilationJobStreamOperations(object): """DscCompilationJobStreamOperations operations. @@ -44,14 +83,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -70,34 +109,24 @@ def list_by_job( 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') + + 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, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +135,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 + 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 48af11730a06d..f6daab12868c2 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 @@ -5,23 +5,277 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2019-06-01" + accept = "text/powershell" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + query_parameters['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DscConfigurationOperations(object): """DscConfigurationOperations operations. @@ -45,14 +299,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +325,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +350,15 @@ def delete( 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. @@ -132,34 +377,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +403,19 @@ 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 + + @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"], + **kwargs: Any + ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -189,8 +426,8 @@ 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 str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "text/plain; charset=utf-8", "application/json." :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 @@ -201,48 +438,40 @@ def create_or_update( 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 + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = None + _content = None + 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) + + 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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +484,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}/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, + **kwargs: Any + ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -276,8 +507,8 @@ def update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :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 str content_type: Media type of the body sent to the API. Default value is + "application/json". Allowed values are: "text/plain; charset=utf-8", "application/json." :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 @@ -288,51 +519,40 @@ def update( 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 + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = None + _content = None + 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) + + 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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +561,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 + + @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. @@ -369,28 +591,18 @@ def get_content( 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) - - # 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 = 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -404,19 +616,21 @@ 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 + + @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. @@ -432,7 +646,8 @@ def list_by_automation_account( :param inlinecount: Return total rows. :type inlinecount: 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 """ @@ -441,44 +656,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -491,12 +703,13 @@ def get_next(next_link=None): 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 ) 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 45317cc8dfce6..60431565d77ad 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 @@ -5,25 +5,196 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + query_parameters['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DscNodeConfigurationOperations(object): """DscNodeConfigurationOperations operations. @@ -47,14 +218,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -73,34 +244,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -108,14 +269,15 @@ def delete( 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. @@ -134,34 +296,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +322,46 @@ 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 + 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"] + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + parameters: "_models.DscNodeConfigurationCreateOrUpdateParameters", + **kwargs: Any + ) -> Optional["_models.DscNodeConfiguration"]: cls = kwargs.pop('cls', None) # type: ClsType[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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +371,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 + + @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. @@ -252,15 +396,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( 'polling_interval', @@ -273,28 +421,21 @@ def begin_create_or_update( automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -306,19 +447,20 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -334,8 +476,10 @@ def list_by_automation_account( :param inlinecount: Return total rows. :type inlinecount: 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"] @@ -343,44 +487,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -393,12 +534,13 @@ def get_next(next_link=None): 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 ) 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 49866da11b67d..a4610d9b53c02 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 @@ -5,23 +5,194 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + node_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if inlinecount is not None: + query_parameters['$inlinecount'] = _SERIALIZER.query("inlinecount", inlinecount, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DscNodeOperations(object): """DscNodeOperations operations. @@ -45,14 +216,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +242,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +267,15 @@ def delete( 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. @@ -132,34 +294,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +320,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 + + @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. @@ -199,39 +353,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,19 +384,21 @@ 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 + + @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. @@ -277,44 +423,41 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -327,12 +470,13 @@ def get_next(next_link=None): 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 ) 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 f1a689f580b74..b1b5ea66a9083 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 @@ -5,23 +5,64 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class FieldsOperations(object): """FieldsOperations operations. @@ -45,15 +86,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,38 +115,37 @@ def list_by_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -118,12 +158,13 @@ def get_next(next_link=None): 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 ) 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 63abed20de875..d006247b10e47 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class HybridRunbookWorkerGroupOperations(object): """HybridRunbookWorkerGroupOperations operations. @@ -45,14 +253,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +279,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +304,15 @@ def delete( 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. @@ -132,34 +331,90 @@ def get( 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'), + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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) + + 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. + + :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 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 } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +423,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,7 +445,8 @@ 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 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 @@ -199,39 +457,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'HybridRunbookWorkerGroupCreateOrUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,16 +488,18 @@ 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 + + @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. @@ -259,8 +509,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -268,38 +520,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -312,12 +561,13 @@ def get_next(next_link=None): 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 ) 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 0000000000000..c04e96c5146c1 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,601 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class HybridRunbookWorkersOperations(object): + """HybridRunbookWorkersOperations 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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def delete( + 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 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', {})) + + + 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 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', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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. + :type filter: 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkersListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 2afce74497f4d..075c67af9470e 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 @@ -5,23 +5,363 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2019-06-01" + accept = "text/plain" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "text/powershell" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + job_name: str, + *, + json: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobOperations(object): """JobOperations operations. @@ -45,15 +385,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,30 +414,19 @@ def get_output( 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) - # 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 = 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, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,17 +440,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 + + @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. @@ -142,30 +473,19 @@ def get_runbook_content( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -179,17 +499,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 + + @distributed_trace def suspend( 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. @@ -210,36 +532,25 @@ def suspend( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -247,15 +558,16 @@ def suspend( suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + + @distributed_trace def stop( 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. @@ -276,36 +588,25 @@ def stop( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -313,15 +614,16 @@ def stop( 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. @@ -342,36 +644,25 @@ def get( 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') + + 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, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +671,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 + + @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. @@ -414,41 +707,30 @@ def create( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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,17 +739,19 @@ 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 + + @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. @@ -488,40 +772,37 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -534,26 +815,27 @@ def get_next(next_link=None): 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 + @distributed_trace def resume( 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. @@ -574,39 +856,29 @@ def resume( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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 d01e390ea63d1..8a103497d6124 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 @@ -5,23 +5,185 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobScheduleOperations(object): """JobScheduleOperations operations. @@ -45,14 +207,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +233,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +258,15 @@ def delete( 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. @@ -132,34 +285,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +311,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 + + @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. @@ -199,39 +344,29 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,16 +375,18 @@ 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 + + @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. @@ -259,7 +396,8 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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 """ @@ -268,38 +406,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -312,12 +447,13 @@ def get_next(next_link=None): 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 ) 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 4db34971e8ba7..9d30de3f1440f 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 @@ -5,23 +5,112 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class JobStreamOperations(object): """JobStreamOperations operations. @@ -45,16 +134,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -77,37 +166,26 @@ def get( 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') + + 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, + client_request_id=client_request_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +194,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 + + @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. @@ -150,41 +230,39 @@ def list_by_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + client_request_id=client_request_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -197,12 +275,13 @@ def get_next(next_link=None): 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 ) 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 247cd84ff2350..c722d8b3581c7 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 @@ -5,22 +5,59 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class KeysOperations(object): """KeysOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -67,33 +104,23 @@ def list_by_automation_account( 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') + + 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +129,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 + 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 ba38f637ec4fd..2e4a59c8dd315 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 @@ -5,22 +5,59 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class LinkedWorkspaceOperations(object): """LinkedWorkspaceOperations operations. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -67,33 +104,23 @@ def get( 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') + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +129,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 + 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 ccdfd980714ac..d48dcd14be4b5 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ModuleOperations(object): """ModuleOperations operations. @@ -45,14 +249,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +275,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +300,15 @@ def delete( 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. @@ -132,34 +327,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,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 + + @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. @@ -199,39 +386,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +421,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 + + @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. @@ -275,39 +454,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +485,17 @@ 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 + + @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. @@ -341,36 +512,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -383,12 +551,13 @@ def get_next(next_link=None): 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 ) 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 d45cbc7268b91..7f03a1af19d48 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 @@ -5,22 +5,61 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class NodeCountInformationOperations(object): """NodeCountInformationOperations operations. @@ -44,14 +83,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -70,34 +109,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +135,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 + 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 18ae4584c08a4..c9040d824c894 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class NodeReportsOperations(object): """NodeReportsOperations operations. @@ -45,15 +166,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -65,7 +186,8 @@ def list_by_node( :param filter: The filter to apply on the operation. :type filter: 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 """ @@ -74,39 +196,37 @@ def list_by_node( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_node.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -119,26 +239,27 @@ def get_next(next_link=None): 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 + @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. @@ -159,35 +280,25 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +307,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 + + @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. @@ -218,44 +331,34 @@ def get_content( :param report_id: The report id. :type report_id: 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] + cls = kwargs.pop('cls', None) # type: ClsType[Any] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +367,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 + 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 4433d365aee4d..1d4da27541146 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 @@ -5,23 +5,101 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields') + 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ObjectDataTypesOperations(object): """ObjectDataTypesOperations operations. @@ -45,15 +123,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,38 +152,37 @@ def list_fields_by_module_and_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_fields_by_module_and_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -118,25 +195,26 @@ def get_next(next_link=None): 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 + @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. @@ -155,37 +233,35 @@ def list_fields_by_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_fields_by_type.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -198,12 +274,13 @@ def get_next(next_link=None): 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 ) 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 a26716803b061..dc704aee7b27c 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 @@ -5,23 +5,50 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automation/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -98,12 +122,13 @@ def get_next(next_link=None): 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 ) 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 0000000000000..4e9c9ae4b7d34 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,562 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class PrivateEndpointConnectionsOperations(object): + """PrivateEndpointConnectionsOperations 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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 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 + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + 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( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = 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 + ) + 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}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **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', {})) + + + 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, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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( + 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 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 + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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._delete_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x,y,z: x, + **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 = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + 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 0000000000000..0d9342665756f --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py @@ -0,0 +1,158 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class PrivateLinkResourcesOperations(object): + """PrivateLinkResourcesOperations 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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @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 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 + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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, + template_url=self.automation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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(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 f28cd6987093d..ac753dd42b2d4 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + package_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Python2PackageOperations(object): """Python2PackageOperations operations. @@ -45,14 +249,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( 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. @@ -71,34 +275,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -106,14 +300,15 @@ def delete( 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. @@ -132,34 +327,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,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 + + @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. @@ -199,39 +386,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +421,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 + + @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. @@ -275,39 +454,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,15 +485,17 @@ 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 + + @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. @@ -341,36 +512,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -383,12 +551,13 @@ def get_next(next_link=None): 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 ) 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 c60a44fca2788..500bf3a632ae8 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 @@ -5,24 +5,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 functools +from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-06-30" + accept = "text/powershell" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_undo_edit_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RunbookDraftOperations(object): """RunbookDraftOperations operations. @@ -46,14 +204,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -63,37 +221,27 @@ def get_content( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType[IO] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -101,81 +249,79 @@ def get_content( 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 + 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]: + cls = kwargs.pop('cls', None) # type: ClsType[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') + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[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') + _content = runbook_content - 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) + 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, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(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 + + @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,20 +330,23 @@ 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 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[IO] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -209,25 +358,21 @@ def begin_replace_content( automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -239,16 +384,17 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -267,34 +413,24 @@ def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +439,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 + + @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. @@ -322,46 +460,41 @@ def undo_edit( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookDraftUndoEditResult"] 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') + + 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, + template_url=self.undo_edit.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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 62717cca25ee5..d3c763119c297 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 @@ -5,25 +5,303 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, IO, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_content_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "text/powershell" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_automation_account_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class RunbookOperations(object): """RunbookOperations operations. @@ -49,63 +327,53 @@ def __init__(self, client, config, serializer, deserializer): def _publish_initial( 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: 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) - # 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 = 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, + template_url=self._publish_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + + @distributed_trace def begin_publish( 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. @@ -116,15 +384,17 @@ def begin_publish( :type runbook_name: 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] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -139,22 +409,14 @@ def begin_publish( cls=lambda x,y,z: x, **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) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -166,16 +428,17 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -185,37 +448,27 @@ def get_content( :param runbook_name: The runbook name. :type runbook_name: 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] + cls = kwargs.pop('cls', None) # type: ClsType[IO] 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') + + 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, + template_url=self.get_content.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -223,22 +476,24 @@ def get_content( 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 + + @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. @@ -257,34 +512,24 @@ def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +538,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 + + @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. @@ -325,39 +572,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +607,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 + + @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. @@ -401,39 +640,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +671,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 + + @distributed_trace def delete( 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. @@ -470,34 +701,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -505,13 +726,14 @@ def delete( 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. @@ -528,36 +750,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -570,12 +789,13 @@ def get_next(next_link=None): 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 ) 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 6bd51aca5617c..6fc3d499e723d 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ScheduleOperations(object): """ScheduleOperations operations. @@ -45,15 +249,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +278,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +314,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 + + @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. @@ -151,39 +347,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +378,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 + + @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. @@ -220,34 +408,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +434,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 + + @distributed_trace def delete( 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. @@ -284,34 +464,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -319,13 +489,14 @@ def delete( 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. @@ -342,36 +513,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -384,12 +552,13 @@ def get_next(next_link=None): 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 ) 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 8fcd0a1009c40..a6767e6c9f1a4 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 @@ -5,22 +5,113 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SoftwareUpdateConfigurationMachineRunsOperations(object): """SoftwareUpdateConfigurationMachineRunsOperations operations. @@ -44,15 +135,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,36 +165,25 @@ def get_by_id( 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 = 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, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,19 +192,21 @@ 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 + + @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. @@ -151,41 +233,27 @@ def list( 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) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +262,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 + 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 229b49a5ca4f8..49c6a2fddee48 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 @@ -5,22 +5,113 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SoftwareUpdateConfigurationRunsOperations(object): """SoftwareUpdateConfigurationRunsOperations operations. @@ -44,15 +135,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -73,36 +164,25 @@ def get_by_id( 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 = 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, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,19 +191,21 @@ 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 + + @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. @@ -150,41 +232,27 @@ def list( 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) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +261,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 + 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 2c1b164f80967..17bb954690460 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 @@ -5,22 +5,198 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + client_request_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if client_request_id is not None: + header_parameters['clientRequestId'] = _SERIALIZER.header("client_request_id", client_request_id, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SoftwareUpdateConfigurationsOperations(object): """SoftwareUpdateConfigurationsOperations operations. @@ -44,16 +220,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -77,41 +253,30 @@ def create( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + client_request_id=client_request_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +289,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 + + @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. @@ -156,36 +323,25 @@ def get_by_name( 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') + + 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, + client_request_id=client_request_id, + template_url=self.get_by_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +350,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 + + @distributed_trace def delete( 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. @@ -226,36 +384,25 @@ def delete( 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) - - # 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 = 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, + client_request_id=client_request_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -263,15 +410,16 @@ def delete( 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. @@ -292,37 +440,25 @@ def list( 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 = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +467,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 + 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 86678aad83856..1bffca18f4baf 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SourceControlOperations(object): """SourceControlOperations operations. @@ -45,15 +253,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +282,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +317,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 + + @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. @@ -150,39 +350,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +381,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 + + @distributed_trace def delete( 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. @@ -219,34 +411,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -254,14 +436,15 @@ def delete( 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. @@ -280,34 +463,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,16 +489,18 @@ 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 + + @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. @@ -335,7 +510,8 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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 """ @@ -344,38 +520,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -388,12 +561,13 @@ def get_next(next_link=None): 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 ) 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 8171b1602c8a9..1c6050838b15e 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 @@ -5,23 +5,154 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SourceControlSyncJobOperations(object): """SourceControlSyncJobOperations operations. @@ -45,16 +176,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -77,40 +208,30 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +240,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 + + @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. @@ -150,35 +273,25 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +300,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 + + @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. @@ -209,8 +324,10 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -218,39 +335,37 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -263,12 +378,13 @@ def get_next(next_link=None): 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 ) 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 fb7d88085d3ae..8e5070e036783 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 @@ -5,23 +5,109 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + 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}') + 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SourceControlSyncJobStreamsOperations(object): """SourceControlSyncJobStreamsOperations operations. @@ -45,16 +131,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,8 +154,10 @@ def list_by_sync_job( :param filter: The filter to apply on the operation. :type filter: 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"] @@ -77,40 +165,39 @@ def list_by_sync_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -123,27 +210,28 @@ def get_next(next_link=None): 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 + @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. @@ -166,36 +254,26 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +282,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 + 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 2c4886e9945d7..14118507732ff 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 @@ -5,23 +5,64 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class StatisticsOperations(object): """StatisticsOperations operations. @@ -45,14 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -62,7 +103,8 @@ def list_by_automation_account( :param filter: The filter to apply on the operation. :type filter: 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 """ @@ -71,38 +113,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -115,12 +154,13 @@ def get_next(next_link=None): 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 ) 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 143df34ab9bc2..0be6c72a2458e 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 @@ -5,22 +5,219 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_resume_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_stop_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_suspend_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TestJobOperations(object): """TestJobOperations operations. @@ -44,15 +241,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -73,39 +270,29 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +301,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 + + @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. @@ -142,34 +331,24 @@ def get( 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 = 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +357,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 + + @distributed_trace def resume( 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. @@ -206,34 +387,24 @@ def resume( 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) - - # 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 = 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, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -241,14 +412,15 @@ def resume( resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + + @distributed_trace def stop( 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. @@ -267,34 +439,24 @@ def stop( 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) - - # 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 = 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, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -302,14 +464,15 @@ def stop( stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + + @distributed_trace def suspend( 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. @@ -328,37 +491,28 @@ def suspend( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 + 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 0b45b5c214e13..952c60e7621e5 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 @@ -5,23 +5,105 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +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: + api_version = "2018-06-30" + 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}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2018-06-30" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TestJobStreamsOperations(object): """TestJobStreamsOperations operations. @@ -45,15 +127,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,35 +156,25 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +183,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 + + @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. @@ -142,39 +216,37 @@ def list_by_test_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -187,12 +259,13 @@ def get_next(next_link=None): 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 ) 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 19cf0634e9825..67229644d8d7d 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 @@ -5,23 +5,60 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-06-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class UsagesOperations(object): """UsagesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,36 +105,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -110,12 +144,13 @@ def get_next(next_link=None): 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 ) 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 5d969e664f972..d2e5e76b665ca 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 @@ -5,23 +5,227 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + variable_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_automation_account_request( + resource_group_name: str, + automation_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VariableOperations(object): """VariableOperations operations. @@ -45,15 +249,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +278,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +313,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 + + @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. @@ -150,39 +346,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') - # 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') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +377,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 + + @distributed_trace def delete( 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. @@ -219,34 +407,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -254,14 +432,15 @@ def delete( 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. @@ -280,34 +459,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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,15 +485,17 @@ 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 + + @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. @@ -341,36 +512,33 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -383,12 +551,13 @@ def get_next(next_link=None): 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 ) 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 0ced3fe30b638..a0d04e6e5b23c 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 @@ -5,23 +5,305 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_start_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_stop_request( + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2020-01-13-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WatcherOperations(object): """WatcherOperations operations. @@ -45,15 +327,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -74,39 +356,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +391,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 + + @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. @@ -147,34 +421,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +447,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 + + @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. @@ -214,39 +480,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +511,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 + + @distributed_trace def delete( 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. @@ -283,34 +541,24 @@ def delete( 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) - - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -318,14 +566,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + + @distributed_trace def start( 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. @@ -344,34 +593,24 @@ def start( 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) - - # 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 = 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, + template_url=self.start.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -379,14 +618,15 @@ def start( start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + + @distributed_trace def stop( 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. @@ -405,34 +645,24 @@ def stop( 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) - - # 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 = 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, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -440,14 +670,15 @@ def stop( 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. @@ -466,38 +697,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -510,12 +738,13 @@ def get_next(next_link=None): 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 ) 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 8f6548f69bc46..d9783d1d31017 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 @@ -5,23 +5,266 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + 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: + api_version = "2015-10-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WebhookOperations(object): """WebhookOperations operations. @@ -45,13 +288,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -68,33 +311,23 @@ def generate_uri( 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) - - # 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 = build_generate_uri_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + template_url=self.generate_uri.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +336,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 + + @distributed_trace def delete( 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. @@ -131,34 +366,24 @@ def delete( 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) - # 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 = 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, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -166,14 +391,15 @@ def delete( 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. @@ -192,34 +418,24 @@ def get( 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') + + 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, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +444,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 + + @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. @@ -259,39 +477,29 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +512,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 + + @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. @@ -335,39 +545,29 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,16 +576,18 @@ 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 + + @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. @@ -404,38 +606,35 @@ def list_by_automation_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - 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, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -448,12 +647,13 @@ def get_next(next_link=None): 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 )