diff --git a/sdk/automation/azure-mgmt-automation/_meta.json b/sdk/automation/azure-mgmt-automation/_meta.json new file mode 100644 index 000000000000..c58734b914fd --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "59b4132646a92806a6aefb0f28d87ad2bd1f21d2", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/automation/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/automation/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/__init__.py index 29580d4d1d84..927665976a33 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 aa9b40978ef3..c4ccb32a8f38 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_automation_client.py @@ -6,103 +6,59 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AutomationClientConfiguration -from .operations import RunbookDraftOperations -from .operations import RunbookOperations -from .operations import TestJobStreamsOperations -from .operations import TestJobOperations -from .operations import Python2PackageOperations -from .operations import AgentRegistrationInformationOperations -from .operations import DscNodeOperations -from .operations import NodeReportsOperations -from .operations import DscCompilationJobOperations -from .operations import DscCompilationJobStreamOperations -from .operations import DscNodeConfigurationOperations -from .operations import NodeCountInformationOperations -from .operations import SoftwareUpdateConfigurationRunsOperations -from .operations import SoftwareUpdateConfigurationMachineRunsOperations -from .operations import SourceControlOperations -from .operations import SourceControlSyncJobOperations -from .operations import SourceControlSyncJobStreamsOperations -from .operations import JobOperations -from .operations import JobStreamOperations -from .operations import AutomationAccountOperations -from .operations import StatisticsOperations -from .operations import UsagesOperations -from .operations import KeysOperations -from .operations import CertificateOperations -from .operations import ConnectionOperations -from .operations import ConnectionTypeOperations -from .operations import CredentialOperations -from .operations import DscConfigurationOperations -from .operations import SoftwareUpdateConfigurationsOperations -from .operations import HybridRunbookWorkerGroupOperations -from .operations import JobScheduleOperations -from .operations import LinkedWorkspaceOperations -from .operations import ActivityOperations -from .operations import ModuleOperations -from .operations import ObjectDataTypesOperations -from .operations import FieldsOperations -from .operations import Operations -from .operations import ScheduleOperations -from .operations import VariableOperations -from .operations import WatcherOperations -from .operations import WebhookOperations from . import models +from ._configuration import AutomationClientConfiguration +from .operations import ActivityOperations, AgentRegistrationInformationOperations, AutomationAccountOperations, AutomationClientOperationsMixin, CertificateOperations, ConnectionOperations, ConnectionTypeOperations, CredentialOperations, DscCompilationJobOperations, DscCompilationJobStreamOperations, DscConfigurationOperations, DscNodeConfigurationOperations, DscNodeOperations, FieldsOperations, HybridRunbookWorkerGroupOperations, HybridRunbookWorkersOperations, JobOperations, JobScheduleOperations, JobStreamOperations, KeysOperations, LinkedWorkspaceOperations, ModuleOperations, NodeCountInformationOperations, NodeReportsOperations, ObjectDataTypesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, RunbookDraftOperations, RunbookOperations, ScheduleOperations, SoftwareUpdateConfigurationMachineRunsOperations, SoftwareUpdateConfigurationRunsOperations, SoftwareUpdateConfigurationsOperations, SourceControlOperations, SourceControlSyncJobOperations, SourceControlSyncJobStreamsOperations, StatisticsOperations, TestJobOperations, TestJobStreamsOperations, UsagesOperations, VariableOperations, WatcherOperations, WebhookOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Automation Client. - :ivar runbook_draft: RunbookDraftOperations operations - :vartype runbook_draft: azure.mgmt.automation.operations.RunbookDraftOperations - :ivar runbook: RunbookOperations operations - :vartype runbook: azure.mgmt.automation.operations.RunbookOperations - :ivar test_job_streams: TestJobStreamsOperations operations - :vartype test_job_streams: azure.mgmt.automation.operations.TestJobStreamsOperations - :ivar test_job: TestJobOperations operations - :vartype test_job: azure.mgmt.automation.operations.TestJobOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.automation.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.automation.operations.PrivateLinkResourcesOperations :ivar python2_package: Python2PackageOperations operations :vartype python2_package: azure.mgmt.automation.operations.Python2PackageOperations :ivar agent_registration_information: AgentRegistrationInformationOperations operations - :vartype agent_registration_information: azure.mgmt.automation.operations.AgentRegistrationInformationOperations + :vartype agent_registration_information: + azure.mgmt.automation.operations.AgentRegistrationInformationOperations :ivar dsc_node: DscNodeOperations operations :vartype dsc_node: azure.mgmt.automation.operations.DscNodeOperations :ivar node_reports: NodeReportsOperations operations :vartype node_reports: azure.mgmt.automation.operations.NodeReportsOperations + :ivar dsc_node_configuration: DscNodeConfigurationOperations operations + :vartype dsc_node_configuration: + azure.mgmt.automation.operations.DscNodeConfigurationOperations :ivar dsc_compilation_job: DscCompilationJobOperations operations :vartype dsc_compilation_job: azure.mgmt.automation.operations.DscCompilationJobOperations :ivar dsc_compilation_job_stream: DscCompilationJobStreamOperations operations - :vartype dsc_compilation_job_stream: azure.mgmt.automation.operations.DscCompilationJobStreamOperations - :ivar dsc_node_configuration: DscNodeConfigurationOperations operations - :vartype dsc_node_configuration: azure.mgmt.automation.operations.DscNodeConfigurationOperations + :vartype dsc_compilation_job_stream: + azure.mgmt.automation.operations.DscCompilationJobStreamOperations :ivar node_count_information: NodeCountInformationOperations operations - :vartype node_count_information: azure.mgmt.automation.operations.NodeCountInformationOperations - :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations - :vartype software_update_configuration_runs: azure.mgmt.automation.operations.SoftwareUpdateConfigurationRunsOperations - :ivar software_update_configuration_machine_runs: SoftwareUpdateConfigurationMachineRunsOperations operations - :vartype software_update_configuration_machine_runs: azure.mgmt.automation.operations.SoftwareUpdateConfigurationMachineRunsOperations + :vartype node_count_information: + azure.mgmt.automation.operations.NodeCountInformationOperations :ivar source_control: SourceControlOperations operations :vartype source_control: azure.mgmt.automation.operations.SourceControlOperations :ivar source_control_sync_job: SourceControlSyncJobOperations operations - :vartype source_control_sync_job: azure.mgmt.automation.operations.SourceControlSyncJobOperations + :vartype source_control_sync_job: + azure.mgmt.automation.operations.SourceControlSyncJobOperations :ivar source_control_sync_job_streams: SourceControlSyncJobStreamsOperations operations - :vartype source_control_sync_job_streams: azure.mgmt.automation.operations.SourceControlSyncJobStreamsOperations - :ivar job: JobOperations operations - :vartype job: azure.mgmt.automation.operations.JobOperations - :ivar job_stream: JobStreamOperations operations - :vartype job_stream: azure.mgmt.automation.operations.JobStreamOperations + :vartype source_control_sync_job_streams: + azure.mgmt.automation.operations.SourceControlSyncJobStreamsOperations :ivar automation_account: AutomationAccountOperations operations :vartype automation_account: azure.mgmt.automation.operations.AutomationAccountOperations :ivar statistics: StatisticsOperations operations @@ -119,12 +75,9 @@ class AutomationClient(object): :vartype connection_type: azure.mgmt.automation.operations.ConnectionTypeOperations :ivar credential: CredentialOperations operations :vartype credential: azure.mgmt.automation.operations.CredentialOperations - :ivar dsc_configuration: DscConfigurationOperations operations - :vartype dsc_configuration: azure.mgmt.automation.operations.DscConfigurationOperations - :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations - :vartype software_update_configurations: azure.mgmt.automation.operations.SoftwareUpdateConfigurationsOperations :ivar hybrid_runbook_worker_group: HybridRunbookWorkerGroupOperations operations - :vartype hybrid_runbook_worker_group: azure.mgmt.automation.operations.HybridRunbookWorkerGroupOperations + :vartype hybrid_runbook_worker_group: + azure.mgmt.automation.operations.HybridRunbookWorkerGroupOperations :ivar job_schedule: JobScheduleOperations operations :vartype job_schedule: azure.mgmt.automation.operations.JobScheduleOperations :ivar linked_workspace: LinkedWorkspaceOperations operations @@ -137,123 +90,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: 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 b9e9ba1a6151..4d1356d8bcfa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AutomationClientConfiguration(Configuration): +class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -29,22 +27,22 @@ class AutomationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AutomationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 653b73a4a199..e5754a47ce68 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 c537136a35f8..f67ad3868dd3 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 0468a4e97c2e..3c928ab85264 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_automation_client.py @@ -6,101 +6,59 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AutomationClientConfiguration -from .operations import RunbookDraftOperations -from .operations import RunbookOperations -from .operations import TestJobStreamsOperations -from .operations import TestJobOperations -from .operations import Python2PackageOperations -from .operations import AgentRegistrationInformationOperations -from .operations import DscNodeOperations -from .operations import NodeReportsOperations -from .operations import DscCompilationJobOperations -from .operations import DscCompilationJobStreamOperations -from .operations import DscNodeConfigurationOperations -from .operations import NodeCountInformationOperations -from .operations import SoftwareUpdateConfigurationRunsOperations -from .operations import SoftwareUpdateConfigurationMachineRunsOperations -from .operations import SourceControlOperations -from .operations import SourceControlSyncJobOperations -from .operations import SourceControlSyncJobStreamsOperations -from .operations import JobOperations -from .operations import JobStreamOperations -from .operations import AutomationAccountOperations -from .operations import StatisticsOperations -from .operations import UsagesOperations -from .operations import KeysOperations -from .operations import CertificateOperations -from .operations import ConnectionOperations -from .operations import ConnectionTypeOperations -from .operations import CredentialOperations -from .operations import DscConfigurationOperations -from .operations import SoftwareUpdateConfigurationsOperations -from .operations import HybridRunbookWorkerGroupOperations -from .operations import JobScheduleOperations -from .operations import LinkedWorkspaceOperations -from .operations import ActivityOperations -from .operations import ModuleOperations -from .operations import ObjectDataTypesOperations -from .operations import FieldsOperations -from .operations import Operations -from .operations import ScheduleOperations -from .operations import VariableOperations -from .operations import WatcherOperations -from .operations import WebhookOperations from .. import models +from ._configuration import AutomationClientConfiguration +from .operations import ActivityOperations, AgentRegistrationInformationOperations, AutomationAccountOperations, AutomationClientOperationsMixin, CertificateOperations, ConnectionOperations, ConnectionTypeOperations, CredentialOperations, DscCompilationJobOperations, DscCompilationJobStreamOperations, DscConfigurationOperations, DscNodeConfigurationOperations, DscNodeOperations, FieldsOperations, HybridRunbookWorkerGroupOperations, HybridRunbookWorkersOperations, JobOperations, JobScheduleOperations, JobStreamOperations, KeysOperations, LinkedWorkspaceOperations, ModuleOperations, NodeCountInformationOperations, NodeReportsOperations, ObjectDataTypesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, Python2PackageOperations, RunbookDraftOperations, RunbookOperations, ScheduleOperations, SoftwareUpdateConfigurationMachineRunsOperations, SoftwareUpdateConfigurationRunsOperations, SoftwareUpdateConfigurationsOperations, SourceControlOperations, SourceControlSyncJobOperations, SourceControlSyncJobStreamsOperations, StatisticsOperations, TestJobOperations, TestJobStreamsOperations, UsagesOperations, VariableOperations, WatcherOperations, WebhookOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AutomationClient(object): +class AutomationClient(AutomationClientOperationsMixin): # pylint: disable=too-many-instance-attributes """Automation Client. - :ivar runbook_draft: RunbookDraftOperations operations - :vartype runbook_draft: azure.mgmt.automation.aio.operations.RunbookDraftOperations - :ivar runbook: RunbookOperations operations - :vartype runbook: azure.mgmt.automation.aio.operations.RunbookOperations - :ivar test_job_streams: TestJobStreamsOperations operations - :vartype test_job_streams: azure.mgmt.automation.aio.operations.TestJobStreamsOperations - :ivar test_job: TestJobOperations operations - :vartype test_job: azure.mgmt.automation.aio.operations.TestJobOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.automation.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.automation.aio.operations.PrivateLinkResourcesOperations :ivar python2_package: Python2PackageOperations operations :vartype python2_package: azure.mgmt.automation.aio.operations.Python2PackageOperations :ivar agent_registration_information: AgentRegistrationInformationOperations operations - :vartype agent_registration_information: azure.mgmt.automation.aio.operations.AgentRegistrationInformationOperations + :vartype agent_registration_information: + azure.mgmt.automation.aio.operations.AgentRegistrationInformationOperations :ivar dsc_node: DscNodeOperations operations :vartype dsc_node: azure.mgmt.automation.aio.operations.DscNodeOperations :ivar node_reports: NodeReportsOperations operations :vartype node_reports: azure.mgmt.automation.aio.operations.NodeReportsOperations + :ivar dsc_node_configuration: DscNodeConfigurationOperations operations + :vartype dsc_node_configuration: + azure.mgmt.automation.aio.operations.DscNodeConfigurationOperations :ivar dsc_compilation_job: DscCompilationJobOperations operations :vartype dsc_compilation_job: azure.mgmt.automation.aio.operations.DscCompilationJobOperations :ivar dsc_compilation_job_stream: DscCompilationJobStreamOperations operations - :vartype dsc_compilation_job_stream: azure.mgmt.automation.aio.operations.DscCompilationJobStreamOperations - :ivar dsc_node_configuration: DscNodeConfigurationOperations operations - :vartype dsc_node_configuration: azure.mgmt.automation.aio.operations.DscNodeConfigurationOperations + :vartype dsc_compilation_job_stream: + azure.mgmt.automation.aio.operations.DscCompilationJobStreamOperations :ivar node_count_information: NodeCountInformationOperations operations - :vartype node_count_information: azure.mgmt.automation.aio.operations.NodeCountInformationOperations - :ivar software_update_configuration_runs: SoftwareUpdateConfigurationRunsOperations operations - :vartype software_update_configuration_runs: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationRunsOperations - :ivar software_update_configuration_machine_runs: SoftwareUpdateConfigurationMachineRunsOperations operations - :vartype software_update_configuration_machine_runs: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationMachineRunsOperations + :vartype node_count_information: + azure.mgmt.automation.aio.operations.NodeCountInformationOperations :ivar source_control: SourceControlOperations operations :vartype source_control: azure.mgmt.automation.aio.operations.SourceControlOperations :ivar source_control_sync_job: SourceControlSyncJobOperations operations - :vartype source_control_sync_job: azure.mgmt.automation.aio.operations.SourceControlSyncJobOperations + :vartype source_control_sync_job: + azure.mgmt.automation.aio.operations.SourceControlSyncJobOperations :ivar source_control_sync_job_streams: SourceControlSyncJobStreamsOperations operations - :vartype source_control_sync_job_streams: azure.mgmt.automation.aio.operations.SourceControlSyncJobStreamsOperations - :ivar job: JobOperations operations - :vartype job: azure.mgmt.automation.aio.operations.JobOperations - :ivar job_stream: JobStreamOperations operations - :vartype job_stream: azure.mgmt.automation.aio.operations.JobStreamOperations + :vartype source_control_sync_job_streams: + azure.mgmt.automation.aio.operations.SourceControlSyncJobStreamsOperations :ivar automation_account: AutomationAccountOperations operations :vartype automation_account: azure.mgmt.automation.aio.operations.AutomationAccountOperations :ivar statistics: StatisticsOperations operations @@ -117,12 +75,9 @@ class AutomationClient(object): :vartype connection_type: azure.mgmt.automation.aio.operations.ConnectionTypeOperations :ivar credential: CredentialOperations operations :vartype credential: azure.mgmt.automation.aio.operations.CredentialOperations - :ivar dsc_configuration: DscConfigurationOperations operations - :vartype dsc_configuration: azure.mgmt.automation.aio.operations.DscConfigurationOperations - :ivar software_update_configurations: SoftwareUpdateConfigurationsOperations operations - :vartype software_update_configurations: azure.mgmt.automation.aio.operations.SoftwareUpdateConfigurationsOperations :ivar hybrid_runbook_worker_group: HybridRunbookWorkerGroupOperations operations - :vartype hybrid_runbook_worker_group: azure.mgmt.automation.aio.operations.HybridRunbookWorkerGroupOperations + :vartype hybrid_runbook_worker_group: + azure.mgmt.automation.aio.operations.HybridRunbookWorkerGroupOperations :ivar job_schedule: JobScheduleOperations operations :vartype job_schedule: azure.mgmt.automation.aio.operations.JobScheduleOperations :ivar linked_workspace: LinkedWorkspaceOperations operations @@ -135,122 +90,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 dce38b50c718..a8ad2e83bdfc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AutomationClientConfiguration(Configuration): +class AutomationClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AutomationClient. Note that all parameters used to create this instance are saved as instance @@ -27,7 +27,8 @@ class AutomationClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str """ @@ -37,11 +38,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AutomationClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AutomationClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /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 d7371312a9c8..23136da95dd4 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 f3fd231d0257..6e5897460451 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_activity_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def get( :type module_name: str :param activity_name: The name of activity. :type activity_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity @@ -69,35 +77,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +111,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 + 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. @@ -123,47 +131,53 @@ def list_by_module( :type automation_account_name: str :param module_name: The name of module. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActivityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ActivityListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_module.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_module.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -172,17 +186,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_module.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities'} # type: ignore + list_by_module.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py index c0f984e15215..53bfcfb2ade0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_agent_registration_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -52,6 +56,9 @@ async def get( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration @@ -62,33 +69,30 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +101,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 + 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. @@ -114,6 +121,9 @@ async def regenerate_key( :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration @@ -124,38 +134,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') + + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +170,6 @@ async def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey'} # type: ignore + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py index c46bc8efda84..79e12ec71fcb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_account_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -56,6 +61,9 @@ async def update( :type automation_account_name: str :param parameters: Parameters supplied to the update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -66,38 +74,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -106,14 +110,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 + 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. @@ -123,6 +130,9 @@ async def create_or_update( :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -133,38 +143,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +183,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete an automation account. @@ -191,6 +200,9 @@ async def delete( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -201,45 +213,44 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> "_models.AutomationAccount": """Get information about an Automation Account. @@ -247,6 +258,9 @@ async def get( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -257,33 +271,30 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -292,56 +303,64 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AutomationAccountListResult"]: """Retrieve a list of accounts within a given resource group. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -350,67 +369,77 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts"} # type: ignore + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AutomationAccountListResult"]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -419,17 +448,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py new file mode 100644 index 000000000000..bd4cbf88d783 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_automation_client_operations.py @@ -0,0 +1,93 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GraphicalRunbookContent, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GraphicalRunbookContent"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GraphicalRunbookContent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + convert_graph_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py index 9550ca4ad5a9..e99521a63e6b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, certificate_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the certificate. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, certificate_name: str, - **kwargs + **kwargs: Any ) -> "_models.Certificate": """Retrieve the certificate identified by certificate name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +246,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 + 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. @@ -257,6 +269,9 @@ async def update( :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -267,39 +282,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,52 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CertificateListResult] + :return: An iterator like instance of either CertificateListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CertificateListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,17 +390,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py index cfaacdf48919..7174e629cb1d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, connection_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, connection_name: str, - **kwargs + **kwargs: Any ) -> "_models.Connection": """Retrieve the connection identified by connection name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +246,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 + 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. @@ -257,6 +269,9 @@ async def update( :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -267,39 +282,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,52 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionListResult] + :return: An iterator like instance of either ConnectionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,17 +390,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py index 921ca73acdfd..fd4d59c2e5d6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_connection_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the connection type. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, connection_type_name: str, - **kwargs + **kwargs: Any ) -> "_models.ConnectionType": """Retrieve the connection type identified by connection type name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -183,6 +193,9 @@ async def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType @@ -193,39 +206,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [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 +243,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 + 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. @@ -248,46 +260,52 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionTypeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] + :return: An iterator like instance of either ConnectionTypeListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionTypeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -296,17 +314,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py index b70ff90697ff..eb4cee4e5596 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_credential_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, credential_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the credential. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, credential_name: str, - **kwargs + **kwargs: Any ) -> "_models.Credential": """Retrieve the credential identified by credential name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +246,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 + 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. @@ -257,6 +269,9 @@ async def update( :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -267,39 +282,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,52 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CredentialListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CredentialListResult] + :return: An iterator like instance of either CredentialListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.CredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,7 +390,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,7 +403,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py index bd5b087ef960..fb1478ed6ce0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 +53,42 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [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 +96,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 + _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. @@ -117,16 +119,24 @@ async def begin_create( :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DscCompilationJob or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DscCompilationJob or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscCompilationJob] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( @@ -140,28 +150,22 @@ async def begin_create( automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -171,16 +175,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, compilation_job_name: str, - **kwargs + **kwargs: Any ) -> "_models.DscCompilationJob": """Retrieve the Dsc configuration compilation job identified by job id. @@ -190,6 +195,9 @@ async def get( :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. :type compilation_job_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob @@ -200,34 +208,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +241,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 + 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. @@ -251,50 +259,56 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscCompilationJobListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] + :return: An iterator like instance of either DscCompilationJobListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJobListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -303,28 +317,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs"} # type: ignore + @distributed_trace_async async def get_stream( self, resource_group_name: str, automation_account_name: str, job_id: str, job_stream_id: str, - **kwargs + **kwargs: Any ) -> "_models.JobStream": """Retrieve the job stream identified by job stream id. @@ -336,6 +356,9 @@ async def get_stream( :type job_id: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -346,35 +369,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +403,6 @@ async def get_stream( return cls(pipeline_response, deserialized, {}) return deserialized - get_stream.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}'} # type: ignore + + get_stream.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py index b5ceebb497b1..ef0e7d964746 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_compilation_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -55,6 +59,9 @@ async def list_by_job( :type automation_account_name: str :param job_id: The job id. :type job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult @@ -65,34 +72,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +105,6 @@ async def list_by_job( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams'} # type: ignore + + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py index fa2cc5f3e6a9..ead41d1f8a17 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc configuration identified by configuration name. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> "_models.DscConfiguration": """Retrieve the configuration identified by configuration name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,20 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, automation_account_name: str, configuration_name: str, parameters: Union[str, "_models.DscConfigurationCreateOrUpdateParameters"], - **kwargs + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. @@ -182,8 +194,12 @@ async def create_or_update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain; charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -194,48 +210,45 @@ 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 + + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +261,20 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, automation_account_name: str, configuration_name: str, parameters: Optional[Union[str, "_models.DscConfigurationUpdateParameters"]] = None, - **kwargs + *, + content_type: Optional[str] = "application/json", + **kwargs: Any ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. @@ -266,10 +284,14 @@ async def update( :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. :type configuration_name: str - :param parameters: The create or update parameters for configuration. + :param parameters: The create or update parameters for configuration. Default value is None. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain; charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -280,51 +302,45 @@ 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 + + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +349,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, configuration_name: str, - **kwargs + **kwargs: Any ) -> str: """Retrieve the configuration script identified by configuration name. @@ -350,6 +369,9 @@ async def get_content( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -360,29 +382,26 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + ) + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,8 +414,11 @@ async def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -405,7 +427,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. @@ -413,62 +435,68 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] + :return: An iterator like instance of either DscConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -477,17 +505,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py index 1b76e60c6110..812fea5d087d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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 +47,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the Dsc node configurations by node configuration. @@ -58,6 +63,9 @@ async def delete( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -68,47 +76,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_configuration_name: str, - **kwargs + **kwargs: Any ) -> "_models.DscNodeConfiguration": """Retrieve the Dsc node configurations by node configuration. @@ -118,6 +125,9 @@ async def get( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration @@ -128,34 +138,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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,7 +171,9 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + async def _create_or_update_initial( self, @@ -172,47 +181,42 @@ async def _create_or_update_initial( 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +226,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 + _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. @@ -242,16 +249,24 @@ async def begin_create_or_update( :type node_configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DscNodeConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( @@ -265,28 +280,22 @@ async def begin_create_or_update( automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -296,10 +305,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -308,7 +318,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. @@ -316,62 +326,68 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] + :return: An iterator like instance of either DscNodeConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -380,17 +396,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py index c57d748bf2ee..abe835aae44e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_dsc_node_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, node_id: str, - **kwargs + **kwargs: Any ) -> None: """Delete the dsc node identified by node id. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, - **kwargs + **kwargs: Any ) -> "_models.DscNode": """Retrieve the dsc node identified by node id. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def update( :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -233,8 +242,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, @@ -243,7 +255,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. @@ -251,62 +263,67 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -315,17 +332,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py index 46dad5908054..079485f6f542 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_fields_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.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 +44,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. @@ -59,48 +63,55 @@ def list_by_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -109,17 +120,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py index 26bbf388d578..021aa5622d0d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_worker_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a hybrid runbook worker group. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, hybrid_runbook_worker_group_name: str, - **kwargs + **kwargs: Any ) -> "_models.HybridRunbookWorkerGroup": """Retrieve a hybrid runbook worker group. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup @@ -126,34 +136,106 @@ 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'), + + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) + + 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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorkerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +244,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 +266,11 @@ async def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str :param parameters: The hybrid runbook worker group. - :type parameters: ~azure.mgmt.automation.models.HybridRunbookWorkerGroupUpdateParameters + :type parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup @@ -192,39 +281,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridRunbookWorkerGroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -233,14 +318,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 + 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. @@ -248,50 +336,56 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] + :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroupsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -300,17 +394,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py new file mode 100644 index 000000000000..f63e39e3ef33 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,432 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> None: + """Delete a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2021-06-22") # type: 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, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> "_models.HybridRunbookWorker": + """Retrieve a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_creation_parameters: "_models.HybridRunbookWorkerCreateParameters", + **kwargs: Any + ) -> "_models.HybridRunbookWorker": + """Create a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid + runbook worker. + :type hybrid_runbook_worker_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace_async + async def move( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_move_parameters: "_models.HybridRunbookWorkerMoveParameters", + **kwargs: Any + ) -> None: + """Move a hybrid worker to a different group. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. + :type hybrid_runbook_worker_move_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + move.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move"} # type: ignore + + + @distributed_trace + def list_by_hybrid_runbook_worker_group( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.HybridRunbookWorkersListResult"]: + """Retrieve a list of hybrid runbook workers. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridRunbookWorkersListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkersListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkersListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_hybrid_runbook_worker_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py index e0d98349d7c7..591fadf1d3b3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -57,8 +62,11 @@ async def get_output( :type automation_account_name: str :param job_name: The name of the job to be created. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -69,31 +77,27 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + ) + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,15 +110,18 @@ async def get_output( return cls(pipeline_response, deserialized, {}) return deserialized - get_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output'} # type: ignore + get_output.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output"} # type: ignore + + + @distributed_trace_async async def get_runbook_content( self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> str: """Retrieve the runbook content of the job identified by job name. @@ -124,8 +131,11 @@ async def get_runbook_content( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -136,31 +146,27 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_runbook_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + ) + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,15 +179,18 @@ async def get_runbook_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_runbook_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent'} # type: ignore - async def suspend( + get_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent"} # type: ignore + + + @distributed_trace_async + async def suspend( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Suspend the job identified by job name. @@ -191,8 +200,11 @@ async def suspend( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -203,50 +215,48 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + ) + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend"} # type: ignore + - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Stop the job identified by jobName. @@ -256,8 +266,11 @@ async def stop( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -268,50 +281,48 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + ) + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Job": """Retrieve the job identified by job name. @@ -321,8 +332,11 @@ async def get( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job @@ -333,36 +347,32 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +381,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 + 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 +393,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. @@ -392,8 +405,11 @@ async def create( :type job_name: str :param parameters: The parameters supplied to the create job operation. :type parameters: ~azure.mgmt.automation.models.JobCreateParameters - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job @@ -404,41 +420,36 @@ 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -447,15 +458,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 + 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. @@ -463,54 +477,58 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobListResultV2 or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobListResultV2] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobListResultV2"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -519,28 +537,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs"} # type: ignore - async def resume( + @distributed_trace_async + async def resume( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """Resume the job identified by jobName. @@ -550,8 +574,11 @@ async def resume( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -562,39 +589,36 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py index fe0c83b3f10e..dd2b031a7a49 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, - **kwargs + **kwargs: Any ) -> None: """Delete the job schedule identified by job schedule name. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, job_schedule_id: str, - **kwargs + **kwargs: Any ) -> "_models.JobSchedule": """Retrieve the job schedule identified by job schedule name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create( :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobScheduleCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -233,14 +242,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 + 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. @@ -248,50 +260,56 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] + :return: An iterator like instance of either JobScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -300,17 +318,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py index 7a79fe7c3750..9c5fbaa94a2b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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 +53,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. @@ -60,8 +65,11 @@ async def get( :type job_name: str :param job_stream_id: The job stream id. :type job_stream_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -72,37 +80,33 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +115,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_job( self, resource_group_name: str, @@ -120,7 +127,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. @@ -130,55 +137,61 @@ def list_by_job( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -187,17 +200,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams'} # type: ignore + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py index 580c72ba99ef..a12524939b14 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -52,6 +56,9 @@ async def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult @@ -62,33 +69,30 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +101,6 @@ async def list_by_automation_account( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys'} # type: ignore + + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py index d7b7686e96ce..218d17376563 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_linked_workspace_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -52,6 +56,9 @@ async def get( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace @@ -62,33 +69,30 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +101,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py index 13311f118366..d52076260ddb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_module_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the module by name. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, module_name: str, - **kwargs + **kwargs: Any ) -> "_models.Module": """Retrieve the module identified by module name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create_or_update( :type module_name: str :param parameters: The create or update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +246,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 + 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. @@ -257,6 +269,9 @@ async def update( :type module_name: str :param parameters: The update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -267,39 +282,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,50 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,17 +388,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py index aec38db50025..c8b9d9e9851b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_count_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -55,6 +59,9 @@ async def get( :type automation_account_name: str :param count_type: The type of counts to retrieve. :type count_type: str or ~azure.mgmt.automation.models.CountType + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts @@ -65,34 +72,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NodeCounts', pipeline_response) @@ -101,4 +105,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py index 48789a3db04d..6f9f6d2a4ead 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_node_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -57,51 +62,58 @@ def list_by_node( :type automation_account_name: str :param node_id: The parameters supplied to the list operation. :type node_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeReportListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] + :return: An iterator like instance of either DscNodeReportListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReportListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_node.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_node.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -110,28 +122,34 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_node.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports'} # type: ignore + list_by_node.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, - **kwargs + **kwargs: Any ) -> "_models.DscNodeReport": """Retrieve the Dsc node report data by node id and report id. @@ -143,6 +161,9 @@ async def get( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport @@ -153,35 +174,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +208,19 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}"} # type: ignore + + + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, node_id: str, report_id: str, - **kwargs - ) -> object: + **kwargs: Any + ) -> Any: """Retrieve the Dsc node reports by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -210,45 +231,45 @@ async def get_content( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] + 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +278,6 @@ async def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py index 35507366f372..4bf21d6347be 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_object_data_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.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 +44,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. @@ -59,48 +63,55 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_module_and_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_module_and_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -109,27 +120,33 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_fields_by_module_and_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_module_and_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields"} # type: ignore + @distributed_trace def list_fields_by_type( self, resource_group_name: str, automation_account_name: str, type_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.TypeFieldListResult"]: """Retrieve a list of fields of a given type across all accessible modules. @@ -139,47 +156,53 @@ def list_fields_by_type( :type automation_account_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -188,17 +211,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_fields_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py index 5646e67f5ae1..9c44b52ec67b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.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,46 +44,52 @@ 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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + 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( + api_version=api_version, + 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) @@ -89,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Automation/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Automation/operations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..3199aaf15b87 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,447 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +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 api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": + """Gets a private endpoint connection. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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', {})) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param parameters: + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + api_version=api_version, + 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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + **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 + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..69b2374bffb3 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,131 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.PrivateLinkResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.automation.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + automation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py index b4753198f4b6..8f907d038c46 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_python2_package_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, package_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the python 2 package by name. @@ -56,6 +61,9 @@ async def delete( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -66,47 +74,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, package_name: str, - **kwargs + **kwargs: Any ) -> "_models.Module": """Retrieve the python 2 package identified by package name. @@ -116,6 +123,9 @@ async def get( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -126,34 +136,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +169,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 + 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. @@ -182,6 +192,9 @@ async def create_or_update( :type package_name: str :param parameters: The create or update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -192,39 +205,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +246,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 + 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. @@ -257,6 +269,9 @@ async def update( :type package_name: str :param parameters: The update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -267,39 +282,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,50 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,17 +388,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py index 5118a9366302..5802ade369aa 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_draft_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,18 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union 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 +45,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. @@ -57,52 +61,54 @@ async def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + async def _replace_content_initial( self, @@ -110,65 +116,69 @@ async def _replace_content_initial( automation_account_name: str, runbook_name: str, runbook_content: str, - **kwargs - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] + **kwargs: Any + ) -> Optional[IO]: + 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(runbook_content, 'str') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] + + _content = runbook_content + + request = build_replace_content_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=True, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) + + return deserialized - _replace_content_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + _replace_content_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + + @distributed_trace_async async def begin_replace_content( self, resource_group_name: str, automation_account_name: str, runbook_name: str, runbook_content: str, - **kwargs - ) -> AsyncLROPoller[None]: + **kwargs: Any + ) -> AsyncLROPoller[IO]: """Replaces the runbook draft content. :param resource_group_name: Name of an Azure Resource group. @@ -177,20 +187,27 @@ async def begin_replace_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param runbook_content: The runbook draft content. + :param runbook_content: The runbook draft content. :type runbook_content: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IO or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[IO] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType[IO] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -202,25 +219,22 @@ async def begin_replace_content( automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -230,16 +244,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_replace_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> "_models.RunbookDraft": """Retrieve the runbook draft identified by runbook name. @@ -249,6 +264,9 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft @@ -259,34 +277,31 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +310,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft"} # type: ignore + + + @distributed_trace_async async def undo_edit( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> None: + **kwargs: Any + ) -> "_models.RunbookDraftUndoEditResult": """Undo draft edit to last known published state identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -312,47 +330,52 @@ async def undo_edit( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: RunbookDraftUndoEditResult, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize('RunbookDraftUndoEditResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized + + undo_edit.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit"} # type: ignore - undo_edit.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit'} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py index bed2db8ae795..795b4f7434c0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_runbook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.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]] @@ -43,62 +47,61 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def _publish_initial( + async def _publish_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self._publish_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) - _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + _publish_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore - async def begin_publish( + + @distributed_trace_async + async def begin_publish( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Publish runbook draft. @@ -108,16 +111,22 @@ async def begin_publish( :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -130,25 +139,18 @@ async def begin_publish( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, + api_version=api_version, cls=lambda x,y,z: x, **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: @@ -158,17 +160,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + @distributed_trace_async async def get_content( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs - ) -> str: + **kwargs: Any + ) -> IO: """Retrieve the content of runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -177,59 +180,62 @@ async def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> "_models.Runbook": """Retrieve the runbook identified by runbook name. @@ -239,6 +245,9 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -249,34 +258,31 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +291,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 + 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. @@ -306,6 +315,9 @@ async def create_or_update( :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -316,39 +328,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +369,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 + 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. @@ -381,6 +392,9 @@ async def update( :type runbook_name: str :param parameters: The update parameters for runbook. :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -391,39 +405,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Runbook', pipeline_response) @@ -432,14 +442,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the runbook by name. @@ -449,6 +462,9 @@ async def delete( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -459,46 +475,45 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RunbookListResult"]: """Retrieve a list of runbooks. @@ -506,46 +521,51 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RunbookListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.RunbookListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.RunbookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -554,17 +574,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py index a23002841dcb..0fc3ce2a53d0 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None @@ -69,39 +77,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +119,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 + 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. @@ -135,6 +142,9 @@ async def update( :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule @@ -145,39 +155,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +192,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 + 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. @@ -203,6 +212,9 @@ async def get( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule @@ -213,34 +225,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +258,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, schedule_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the schedule identified by schedule name. @@ -266,6 +278,9 @@ async def delete( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -276,46 +291,45 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ScheduleListResult"]: """Retrieve a list of schedules. @@ -323,46 +337,51 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ScheduleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.ScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -371,17 +390,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py index 3ca0dfd2d7d8..9ec68d7cbde6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_machine_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -57,8 +61,11 @@ async def get_by_id( :param software_update_configuration_machine_run_id: The Id of the software update configuration machine run. :type software_update_configuration_machine_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun @@ -69,36 +76,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_machine_run_id=software_update_configuration_machine_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +110,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}"} # type: ignore + + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -117,7 +123,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. @@ -125,16 +131,20 @@ async def list( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: number of entries you skip before returning results. + :param skip: number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult @@ -145,41 +155,34 @@ 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +191,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py index ae3084d09235..a2b1dc9cfad2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configuration_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -56,8 +60,11 @@ async def get_by_id( :type automation_account_name: str :param software_update_configuration_run_id: The Id of the software update configuration run. :type software_update_configuration_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun @@ -68,36 +75,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_by_id_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + software_update_configuration_run_id=software_update_configuration_run_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +109,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}"} # type: ignore + + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -116,7 +122,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. @@ -124,16 +130,20 @@ async def list( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: Number of entries you skip before returning results. + :param skip: Number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult @@ -144,41 +154,34 @@ 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +190,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py index 5ef8f8af42b3..83c97e8f89de 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_software_update_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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 +51,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. @@ -60,8 +64,11 @@ async def create( :type software_update_configuration_name: str :param parameters: Request body. :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration @@ -72,41 +79,36 @@ 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) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -119,15 +121,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 + 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. @@ -138,8 +143,11 @@ async def get_by_name( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration @@ -150,36 +158,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +192,18 @@ async def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore - async def delete( + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, software_update_configuration_name: str, client_request_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> None: """delete a specific software update configuration. @@ -207,8 +214,11 @@ async def delete( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -219,50 +229,48 @@ 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') - # 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) + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + client_request_id=client_request_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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, automation_account_name: str, client_request_id: Optional[str] = None, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.SoftwareUpdateConfigurationListResult": """Get all software update configurations for the account. @@ -270,10 +278,13 @@ async def list( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult @@ -284,37 +295,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +329,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py index c23577932dfe..9306ac1127b3 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -69,39 +77,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +118,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 + 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. @@ -134,6 +141,9 @@ async def update( :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -144,39 +154,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +191,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, source_control_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the source control. @@ -202,6 +211,9 @@ async def delete( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -212,47 +224,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, source_control_name: str, - **kwargs + **kwargs: Any ) -> "_models.SourceControl": """Retrieve the source control identified by source control name. @@ -262,6 +273,9 @@ async def get( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -272,34 +286,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -323,50 +337,56 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlListResult] + :return: An iterator like instance of either SourceControlListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -375,17 +395,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py index 43a6647ef3a3..0bcda13eec29 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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 +53,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. @@ -62,6 +67,9 @@ async def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob @@ -72,40 +80,36 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJob', pipeline_response) @@ -114,15 +118,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 + 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. @@ -134,6 +141,9 @@ async def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById @@ -144,35 +154,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +188,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 + 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. @@ -199,51 +209,58 @@ def list_by_automation_account( :type automation_account_name: str :param source_control_name: The source control name. :type source_control_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] + :return: An iterator like instance of either SourceControlSyncJobListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -252,17 +269,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py index ca50b6f067f3..633154e01d9d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_source_control_sync_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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 +53,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. @@ -60,52 +65,60 @@ def list_by_sync_job( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] + :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamsListBySyncJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -114,21 +127,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_sync_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams'} # type: ignore + list_by_sync_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -136,7 +155,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. @@ -150,6 +169,9 @@ async def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. :type stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById @@ -160,36 +182,33 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +217,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py index 2a4fe0ae52da..7531eab77603 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_statistics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.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 +44,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. @@ -54,50 +58,56 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StatisticsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.StatisticsListResult] + :return: An iterator like instance of either StatisticsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.StatisticsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.StatisticsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -106,17 +116,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py index ea440aad6497..442660a51bc7 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +43,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. @@ -58,6 +62,9 @@ async def create( :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob @@ -68,39 +75,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TestJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -109,14 +112,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 + 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. @@ -126,6 +132,9 @@ async def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob @@ -136,34 +145,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -172,14 +178,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore - async def resume( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace_async + async def resume( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the test job. @@ -189,6 +198,9 @@ async def resume( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -199,47 +211,46 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume"} # type: ignore + - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Stop the test job. @@ -249,6 +260,9 @@ async def stop( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -259,47 +273,46 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop"} # type: ignore - async def suspend( + + @distributed_trace_async + async def suspend( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, runbook_name: str, - **kwargs + **kwargs: Any ) -> None: """Suspend the test job. @@ -309,6 +322,9 @@ async def suspend( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -319,37 +335,35 @@ 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') - # 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) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py index 55fb84a09c42..206b3ddb31cc 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_test_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def get( :type runbook_name: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -69,35 +77,32 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +111,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 + 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. @@ -124,51 +132,57 @@ def list_by_test_job( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_test_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -177,17 +191,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_test_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams'} # type: ignore + list_by_test_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py index 99ddccc83f14..309b554ac506 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.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 +44,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. @@ -53,46 +57,50 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -101,17 +109,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py index b2d88278a5d9..88d6bd15adc4 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_variable_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -69,39 +77,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +118,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 + 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. @@ -134,6 +141,9 @@ async def update( :type variable_name: str :param parameters: The parameters supplied to the update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -144,39 +154,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +191,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, variable_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the variable. @@ -202,6 +211,9 @@ async def delete( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -212,47 +224,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, variable_name: str, - **kwargs + **kwargs: Any ) -> "_models.Variable": """Retrieve the variable identified by variable name. @@ -262,6 +273,9 @@ async def get( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -272,34 +286,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +319,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 + 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. @@ -322,46 +336,51 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VariableListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.VariableListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.VariableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.VariableListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -370,17 +389,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py index 84c360c06ddc..1fe091599efd 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_watcher_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -59,6 +64,9 @@ async def create_or_update( :type watcher_name: str :param parameters: The create or update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.Watcher + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -69,39 +77,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Watcher') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +118,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 + 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. @@ -131,6 +138,9 @@ async def get( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -141,34 +151,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +184,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 + 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. @@ -197,6 +207,9 @@ async def update( :type watcher_name: str :param parameters: The update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -207,39 +220,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WatcherUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Watcher', pipeline_response) @@ -248,14 +257,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore - async def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the watcher by name. @@ -265,6 +277,9 @@ async def delete( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -275,47 +290,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + - async def start( + @distributed_trace_async + async def start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -325,6 +339,9 @@ async def start( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -335,47 +352,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start"} # type: ignore - async def stop( + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, watcher_name: str, - **kwargs + **kwargs: Any ) -> None: """Resume the watcher identified by watcher name. @@ -385,6 +401,9 @@ async def stop( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -395,47 +414,46 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop"} # type: ignore + + @distributed_trace def list_by_automation_account( self, resource_group_name: str, automation_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.WatcherListResult"]: """Retrieve a list of watchers. @@ -443,50 +461,55 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WatcherListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WatcherListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WatcherListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.WatcherListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -495,17 +518,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py index 8c7cfe5208a2..1d489c7af504 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/aio/operations/_webhook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.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 +45,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. @@ -53,6 +58,9 @@ async def generate_uri( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -63,33 +71,30 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +103,17 @@ async def generate_uri( return cls(pipeline_response, deserialized, {}) return deserialized - generate_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri'} # type: ignore - async def delete( + generate_uri.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, automation_account_name: str, webhook_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete the webhook by name. @@ -115,6 +123,9 @@ async def delete( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -125,47 +136,46 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, automation_account_name: str, webhook_name: str, - **kwargs + **kwargs: Any ) -> "_models.Webhook": """Retrieve the webhook identified by webhook name. @@ -175,6 +185,9 @@ async def get( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -185,34 +198,31 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +231,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 + 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. @@ -241,6 +254,9 @@ async def create_or_update( :type webhook_name: str :param parameters: The create or update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -251,39 +267,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +308,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 + 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. @@ -316,6 +331,9 @@ async def update( :type webhook_name: str :param parameters: The update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -326,39 +344,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -367,14 +381,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 + 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. @@ -382,50 +399,55 @@ def list_by_automation_account( :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebhookListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WebhookListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.automation.models.WebhookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -434,17 +456,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py index 39d1b340a56f..c86e82de17eb 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 2308a221239d..8e01e13b68f7 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. """ @@ -234,8 +251,10 @@ class RunbookTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): POWER_SHELL = "PowerShell" GRAPH_POWER_SHELL_WORKFLOW = "GraphPowerShellWorkflow" GRAPH_POWER_SHELL = "GraphPowerShell" + PYTHON2 = "Python2" + PYTHON3 = "Python3" -class ScheduleDay(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScheduleDay(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, saturday, sunday. """ @@ -248,7 +267,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 +276,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 +294,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 +336,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 aac6ffa75c5f..000000000000 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models.py +++ /dev/null @@ -1,6099 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Activity(msrest.serialization.Model): - """Definition of the activity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Gets or sets the id of the resource. - :type id: str - :ivar name: Gets the name of the activity. - :vartype name: str - :param definition: Gets or sets the user name of the activity. - :type definition: str - :param parameter_sets: Gets or sets the parameter sets of the activity. - :type parameter_sets: list[~azure.mgmt.automation.models.ActivityParameterSet] - :param output_types: Gets or sets the output types of the activity. - :type output_types: list[~azure.mgmt.automation.models.ActivityOutputType] - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'properties.definition', 'type': 'str'}, - 'parameter_sets': {'key': 'properties.parameterSets', 'type': '[ActivityParameterSet]'}, - 'output_types': {'key': 'properties.outputTypes', 'type': '[ActivityOutputType]'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Activity, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = None - self.definition = kwargs.get('definition', None) - self.parameter_sets = kwargs.get('parameter_sets', None) - self.output_types = kwargs.get('output_types', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ActivityListResult(msrest.serialization.Model): - """The response model for the list activity operation. - - :param value: Gets or sets a list of activities. - :type value: list[~azure.mgmt.automation.models.Activity] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Activity]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ActivityOutputType(msrest.serialization.Model): - """Definition of the activity output type. - - :param name: Gets or sets the name of the activity output type. - :type name: str - :param type: Gets or sets the type of the activity output type. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityOutputType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class ActivityParameter(msrest.serialization.Model): - """Definition of the activity parameter. - - :param name: Gets or sets the name of the activity parameter. - :type name: str - :param type: Gets or sets the type of the activity parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value that indicates true if the parameter is - required. If the value is false, the parameter is optional. - :type is_mandatory: bool - :param is_dynamic: Gets or sets a Boolean value that indicates true if the parameter is - dynamic. - :type is_dynamic: bool - :param position: Gets or sets the position of the activity parameter. - :type position: long - :param value_from_pipeline: Gets or sets a Boolean value that indicates true if the parameter - can take values from the incoming pipeline objects. This setting is used if the cmdlet must - access the complete input object. false indicates that the parameter cannot take values from - the complete input object. - :type value_from_pipeline: bool - :param value_from_pipeline_by_property_name: Gets or sets a Boolean value that indicates true - if the parameter can be filled from a property of the incoming pipeline object that has the - same name as this parameter. false indicates that the parameter cannot be filled from the - incoming pipeline object property with the same name. - :type value_from_pipeline_by_property_name: bool - :param value_from_remaining_arguments: Gets or sets a Boolean value that indicates true if the - cmdlet parameter accepts all the remaining command-line arguments that are associated with this - parameter in the form of an array. false if the cmdlet parameter does not accept all the - remaining argument values. - :type value_from_remaining_arguments: bool - :param description: Gets or sets the description of the activity parameter. - :type description: str - :param validation_set: Gets or sets the validation set of activity parameter. - :type validation_set: list[~azure.mgmt.automation.models.ActivityParameterValidationSet] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'is_dynamic': {'key': 'isDynamic', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'long'}, - 'value_from_pipeline': {'key': 'valueFromPipeline', 'type': 'bool'}, - 'value_from_pipeline_by_property_name': {'key': 'valueFromPipelineByPropertyName', 'type': 'bool'}, - 'value_from_remaining_arguments': {'key': 'valueFromRemainingArguments', 'type': 'bool'}, - 'description': {'key': 'description', 'type': 'str'}, - 'validation_set': {'key': 'validationSet', 'type': '[ActivityParameterValidationSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.is_dynamic = kwargs.get('is_dynamic', None) - self.position = kwargs.get('position', None) - self.value_from_pipeline = kwargs.get('value_from_pipeline', None) - self.value_from_pipeline_by_property_name = kwargs.get('value_from_pipeline_by_property_name', None) - self.value_from_remaining_arguments = kwargs.get('value_from_remaining_arguments', None) - self.description = kwargs.get('description', None) - self.validation_set = kwargs.get('validation_set', None) - - -class ActivityParameterSet(msrest.serialization.Model): - """Definition of the activity parameter set. - - :param name: Gets or sets the name of the activity parameter set. - :type name: str - :param parameters: Gets or sets the parameters of the activity parameter set. - :type parameters: list[~azure.mgmt.automation.models.ActivityParameter] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ActivityParameter]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameterSet, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.parameters = kwargs.get('parameters', None) - - -class ActivityParameterValidationSet(msrest.serialization.Model): - """Definition of the activity parameter validation set. - - :param member_value: Gets or sets the name of the activity parameter validation set member. - :type member_value: str - """ - - _attribute_map = { - 'member_value': {'key': 'memberValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityParameterValidationSet, self).__init__(**kwargs) - self.member_value = kwargs.get('member_value', None) - - -class AdvancedSchedule(msrest.serialization.Model): - """The properties of the create Advanced Schedule. - - :param week_days: Days of the week that the job should execute on. - :type week_days: list[str] - :param month_days: Days of the month that the job should execute on. Must be between 1 and 31. - :type month_days: list[int] - :param monthly_occurrences: Occurrences of days within a month. - :type monthly_occurrences: - list[~azure.mgmt.automation.models.AdvancedScheduleMonthlyOccurrence] - """ - - _attribute_map = { - 'week_days': {'key': 'weekDays', 'type': '[str]'}, - 'month_days': {'key': 'monthDays', 'type': '[int]'}, - 'monthly_occurrences': {'key': 'monthlyOccurrences', 'type': '[AdvancedScheduleMonthlyOccurrence]'}, - } - - def __init__( - self, - **kwargs - ): - super(AdvancedSchedule, self).__init__(**kwargs) - self.week_days = kwargs.get('week_days', None) - self.month_days = kwargs.get('month_days', None) - self.monthly_occurrences = kwargs.get('monthly_occurrences', None) - - -class AdvancedScheduleMonthlyOccurrence(msrest.serialization.Model): - """The properties of the create advanced schedule monthly occurrence. - - :param occurrence: Occurrence of the week within the month. Must be between 1 and 5. - :type occurrence: int - :param day: Day of the occurrence. Must be one of monday, tuesday, wednesday, thursday, friday, - saturday, sunday. Possible values include: "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday", "Sunday". - :type day: str or ~azure.mgmt.automation.models.ScheduleDay - """ - - _attribute_map = { - 'occurrence': {'key': 'occurrence', 'type': 'int'}, - 'day': {'key': 'day', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdvancedScheduleMonthlyOccurrence, self).__init__(**kwargs) - self.occurrence = kwargs.get('occurrence', None) - self.day = kwargs.get('day', None) - - -class AgentRegistration(msrest.serialization.Model): - """Definition of the agent registration information type. - - :param dsc_meta_configuration: Gets or sets the dsc meta configuration. - :type dsc_meta_configuration: str - :param endpoint: Gets or sets the dsc server endpoint. - :type endpoint: str - :param keys: Gets or sets the agent registration keys. - :type keys: ~azure.mgmt.automation.models.AgentRegistrationKeys - :param id: Gets or sets the id. - :type id: str - """ - - _attribute_map = { - 'dsc_meta_configuration': {'key': 'dscMetaConfiguration', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - 'keys': {'key': 'keys', 'type': 'AgentRegistrationKeys'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistration, self).__init__(**kwargs) - self.dsc_meta_configuration = kwargs.get('dsc_meta_configuration', None) - self.endpoint = kwargs.get('endpoint', None) - self.keys = kwargs.get('keys', None) - self.id = kwargs.get('id', None) - - -class AgentRegistrationKeys(msrest.serialization.Model): - """Definition of the agent registration keys. - - :param primary: Gets or sets the primary key. - :type primary: str - :param secondary: Gets or sets the secondary key. - :type secondary: str - """ - - _attribute_map = { - 'primary': {'key': 'primary', 'type': 'str'}, - 'secondary': {'key': 'secondary', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistrationKeys, self).__init__(**kwargs) - self.primary = kwargs.get('primary', None) - self.secondary = kwargs.get('secondary', None) - - -class AgentRegistrationRegenerateKeyParameter(msrest.serialization.Model): - """The parameters supplied to the regenerate keys operation. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. Gets or sets the agent registration key name - primary or secondary. - Possible values include: "primary", "secondary". - :type key_name: str or ~azure.mgmt.automation.models.AgentRegistrationKeyName - """ - - _validation = { - 'key_name': {'required': True}, - } - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgentRegistrationRegenerateKeyParameter, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - - -class Resource(msrest.serialization.Model): - """The core properties of ARM resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - - -class AutomationAccount(TrackedResource): - """Definition of the automation account type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param sku: Gets or sets the SKU of account. - :type sku: ~azure.mgmt.automation.models.Sku - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :ivar state: Gets status of account. Possible values include: "Ok", "Unavailable", "Suspended". - :vartype state: str or ~azure.mgmt.automation.models.AutomationAccountState - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccount, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.sku = kwargs.get('sku', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.state = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class AutomationAccountCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update automation account operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - - -class AutomationAccountListResult(msrest.serialization.Model): - """The response model for the list account operation. - - :param value: Gets or sets list of accounts. - :type value: list[~azure.mgmt.automation.models.AutomationAccount] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AutomationAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AutomationAccountUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update automation account operation. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param sku: Gets or sets account SKU. - :type sku: ~azure.mgmt.automation.models.Sku - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'properties.sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationAccountUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - - -class AzureQueryProperties(msrest.serialization.Model): - """Azure query for the update configuration. - - :param scope: List of Subscription or Resource Group ARM Ids. - :type scope: list[str] - :param locations: List of locations to scope the query to. - :type locations: list[str] - :param tag_settings: Tag settings for the VM. - :type tag_settings: ~azure.mgmt.automation.models.TagSettingsProperties - """ - - _attribute_map = { - 'scope': {'key': 'scope', 'type': '[str]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'tag_settings': {'key': 'tagSettings', 'type': 'TagSettingsProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureQueryProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.locations = kwargs.get('locations', None) - self.tag_settings = kwargs.get('tag_settings', None) - - -class Certificate(Resource): - """Definition of the certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar thumbprint: Gets the thumbprint of the certificate. - :vartype thumbprint: str - :ivar expiry_time: Gets the expiry time of the certificate. - :vartype expiry_time: ~datetime.datetime - :ivar is_exportable: Gets the is exportable flag of the certificate. - :vartype is_exportable: bool - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'expiry_time': {'readonly': True}, - 'is_exportable': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'is_exportable': {'key': 'properties.isExportable', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Certificate, self).__init__(**kwargs) - self.thumbprint = None - self.expiry_time = None - self.is_exportable = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class CertificateCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update or replace certificate operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the certificate. - :type name: str - :param base64_value: Required. Gets or sets the base64 encoded value of the certificate. - :type base64_value: str - :param description: Gets or sets the description of the certificate. - :type description: str - :param thumbprint: Gets or sets the thumbprint of the certificate. - :type thumbprint: str - :param is_exportable: Gets or sets the is exportable flag of the certificate. - :type is_exportable: bool - """ - - _validation = { - 'name': {'required': True}, - 'base64_value': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'base64_value': {'key': 'properties.base64Value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'is_exportable': {'key': 'properties.isExportable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.base64_value = kwargs['base64_value'] - self.description = kwargs.get('description', None) - self.thumbprint = kwargs.get('thumbprint', None) - self.is_exportable = kwargs.get('is_exportable', None) - - -class CertificateListResult(msrest.serialization.Model): - """The response model for the list certificate operation. - - :param value: Gets or sets a list of certificates. - :type value: list[~azure.mgmt.automation.models.Certificate] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Certificate]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CertificateUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update certificate operation. - - :param name: Gets or sets the name of the certificate. - :type name: str - :param description: Gets or sets the description of the certificate. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - - -class Connection(Resource): - """Definition of the connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param connection_type: Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty - :ivar field_definition_values: Gets the field definition values of the connection. - :vartype field_definition_values: dict[str, str] - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'field_definition_values': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'connection_type': {'key': 'properties.connectionType', 'type': 'ConnectionTypeAssociationProperty'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Connection, self).__init__(**kwargs) - self.connection_type = kwargs.get('connection_type', None) - self.field_definition_values = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class ConnectionCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update connection operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param connection_type: Required. Gets or sets the connectionType of the connection. - :type connection_type: ~azure.mgmt.automation.models.ConnectionTypeAssociationProperty - :param field_definition_values: Gets or sets the field definition properties of the connection. - :type field_definition_values: dict[str, str] - """ - - _validation = { - 'name': {'required': True}, - 'connection_type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'connection_type': {'key': 'properties.connectionType', 'type': 'ConnectionTypeAssociationProperty'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.description = kwargs.get('description', None) - self.connection_type = kwargs['connection_type'] - self.field_definition_values = kwargs.get('field_definition_values', None) - - -class ConnectionListResult(msrest.serialization.Model): - """The response model for the list connection operation. - - :param value: Gets or sets a list of connection. - :type value: list[~azure.mgmt.automation.models.Connection] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Connection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ConnectionType(msrest.serialization.Model): - """Definition of the connection type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the resource. - :vartype id: str - :ivar name: Gets the name of the connection type. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool - :ivar field_definitions: Gets the field definitions of the connection type. - :vartype field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'field_definitions': {'readonly': True}, - 'creation_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'field_definitions': {'key': 'properties.fieldDefinitions', 'type': '{FieldDefinition}'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionType, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.is_global = kwargs.get('is_global', None) - self.field_definitions = None - self.creation_time = None - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ConnectionTypeAssociationProperty(msrest.serialization.Model): - """The connection type property associated with the entity. - - :param name: Gets or sets the name of the connection type. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ConnectionTypeCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update connection type operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the connection type. - :type name: str - :param is_global: Gets or sets a Boolean value to indicate if the connection type is global. - :type is_global: bool - :param field_definitions: Required. Gets or sets the field definitions of the connection type. - :type field_definitions: dict[str, ~azure.mgmt.automation.models.FieldDefinition] - """ - - _validation = { - 'name': {'required': True}, - 'field_definitions': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'field_definitions': {'key': 'properties.fieldDefinitions', 'type': '{FieldDefinition}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.is_global = kwargs.get('is_global', None) - self.field_definitions = kwargs['field_definitions'] - - -class ConnectionTypeListResult(msrest.serialization.Model): - """The response model for the list connection type operation. - - :param value: Gets or sets a list of connection types. - :type value: list[~azure.mgmt.automation.models.ConnectionType] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConnectionType]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionTypeListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ConnectionUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update connection operation. - - :param name: Gets or sets the name of the connection. - :type name: str - :param description: Gets or sets the description of the connection. - :type description: str - :param field_definition_values: Gets or sets the field definition values of the connection. - :type field_definition_values: dict[str, str] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'field_definition_values': {'key': 'properties.fieldDefinitionValues', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.field_definition_values = kwargs.get('field_definition_values', None) - - -class ContentHash(msrest.serialization.Model): - """Definition of the runbook property type. - - All required parameters must be populated in order to send to Azure. - - :param algorithm: Required. Gets or sets the content hash algorithm used to hash the content. - :type algorithm: str - :param value: Required. Gets or sets expected hash value of the content. - :type value: str - """ - - _validation = { - 'algorithm': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'algorithm': {'key': 'algorithm', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentHash, self).__init__(**kwargs) - self.algorithm = kwargs['algorithm'] - self.value = kwargs['value'] - - -class ContentLink(msrest.serialization.Model): - """Definition of the content link. - - :param uri: Gets or sets the uri of the runbook content. - :type uri: str - :param content_hash: Gets or sets the hash. - :type content_hash: ~azure.mgmt.automation.models.ContentHash - :param version: Gets or sets the version of the content. - :type version: str - """ - - _attribute_map = { - 'uri': {'key': 'uri', 'type': 'str'}, - 'content_hash': {'key': 'contentHash', 'type': 'ContentHash'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) - self.content_hash = kwargs.get('content_hash', None) - self.version = kwargs.get('version', None) - - -class ContentSource(msrest.serialization.Model): - """Definition of the content source. - - :param hash: Gets or sets the hash. - :type hash: ~azure.mgmt.automation.models.ContentHash - :param type: Gets or sets the content source type. Possible values include: "embeddedContent", - "uri". - :type type: str or ~azure.mgmt.automation.models.ContentSourceType - :param value: Gets or sets the value of the content. This is based on the content source type. - :type value: str - :param version: Gets or sets the version of the content. - :type version: str - """ - - _attribute_map = { - 'hash': {'key': 'hash', 'type': 'ContentHash'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentSource, self).__init__(**kwargs) - self.hash = kwargs.get('hash', None) - self.type = kwargs.get('type', None) - self.value = kwargs.get('value', None) - self.version = kwargs.get('version', None) - - -class Credential(Resource): - """Definition of the credential. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar user_name: Gets the user name of the credential. - :vartype user_name: str - :ivar creation_time: Gets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_name': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Credential, self).__init__(**kwargs) - self.user_name = None - self.creation_time = None - self.last_modified_time = None - self.description = kwargs.get('description', None) - - -class CredentialCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update credential operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the credential. - :type name: str - :param user_name: Required. Gets or sets the user name of the credential. - :type user_name: str - :param password: Required. Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str - """ - - _validation = { - 'name': {'required': True}, - 'user_name': {'required': True}, - 'password': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.user_name = kwargs['user_name'] - self.password = kwargs['password'] - self.description = kwargs.get('description', None) - - -class CredentialListResult(msrest.serialization.Model): - """The response model for the list credential operation. - - :param value: Gets or sets a list of credentials. - :type value: list[~azure.mgmt.automation.models.Credential] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Credential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CredentialUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the Update credential operation. - - :param name: Gets or sets the name of the credential. - :type name: str - :param user_name: Gets or sets the user name of the credential. - :type user_name: str - :param password: Gets or sets the password of the credential. - :type password: str - :param description: Gets or sets the description of the credential. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CredentialUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - self.description = kwargs.get('description', None) - - -class DscCompilationJob(Resource): - """Definition of the Dsc Compilation job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param configuration: Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :ivar started_by: Gets the compilation job started by. - :vartype started_by: str - :ivar job_id: Gets the id of the job. - :vartype job_id: str - :ivar creation_time: Gets the creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The current provisioning state of the job. Possible values include: - "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str - :ivar start_time: Gets the start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets the end time of the job. - :vartype end_time: ~datetime.datetime - :ivar exception: Gets the exception of the job. - :vartype exception: str - :ivar last_modified_time: Gets the last modified time of the job. - :vartype last_modified_time: ~datetime.datetime - :ivar last_status_modified_time: Gets the last status modified time of the job. - :vartype last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'started_by': {'readonly': True}, - 'job_id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'exception': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_status_modified_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'started_by': {'key': 'properties.startedBy', 'type': 'str'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'properties.lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJob, self).__init__(**kwargs) - self.configuration = kwargs.get('configuration', None) - self.started_by = None - self.job_id = None - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.run_on = kwargs.get('run_on', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.start_time = None - self.end_time = None - self.exception = None - self.last_modified_time = None - self.last_status_modified_time = None - self.parameters = kwargs.get('parameters', None) - - -class DscCompilationJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create compilation job operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param configuration: Required. Gets or sets the configuration. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _validation = { - 'configuration': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJobCreateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.configuration = kwargs['configuration'] - self.parameters = kwargs.get('parameters', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscCompilationJobListResult(msrest.serialization.Model): - """The response model for the list job operation. - - :param value: Gets or sets a list of Dsc Compilation jobs. - :type value: list[~azure.mgmt.automation.models.DscCompilationJob] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscCompilationJob]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscCompilationJobListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DscConfiguration(TrackedResource): - """Definition of the configuration type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :ivar provisioning_state: Gets or sets the provisioning state of the configuration. Default - value: "Succeeded". - :vartype provisioning_state: str - :param job_count: Gets or sets the job count of the configuration. - :type job_count: int - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param state: Gets or sets the state of the configuration. Possible values include: "New", - "Edit", "Published". - :type state: str or ~azure.mgmt.automation.models.DscConfigurationState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param node_configuration_count: Gets the number of compiled node configurations. - :type node_configuration_count: int - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'job_count': {'key': 'properties.jobCount', 'type': 'int'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'node_configuration_count': {'key': 'properties.nodeConfigurationCount', 'type': 'int'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - provisioning_state = "Succeeded" - - def __init__( - self, - **kwargs - ): - super(DscConfiguration, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.job_count = kwargs.get('job_count', None) - self.parameters = kwargs.get('parameters', None) - self.source = kwargs.get('source', None) - self.state = kwargs.get('state', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.node_configuration_count = kwargs.get('node_configuration_count', None) - self.description = kwargs.get('description', None) - - -class DscConfigurationAssociationProperty(msrest.serialization.Model): - """The Dsc configuration property associated with the entity. - - :param name: Gets or sets the name of the Dsc configuration. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class DscConfigurationCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update configuration operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Required. Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str - """ - - _validation = { - 'source': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.source = kwargs['source'] - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class DscConfigurationListResult(msrest.serialization.Model): - """The response model for the list configuration operation. - - :param value: Gets or sets a list of configurations. - :type value: list[~azure.mgmt.automation.models.DscConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of configurations matching filter criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscConfigurationParameter(msrest.serialization.Model): - """Definition of the configuration parameter type. - - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'int'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationParameter, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.position = kwargs.get('position', None) - self.default_value = kwargs.get('default_value', None) - - -class DscConfigurationUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update configuration operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param parameters: Gets or sets the configuration parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.DscConfigurationParameter] - :param description: Gets or sets the description of the configuration. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscConfigurationUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.source = kwargs.get('source', None) - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class DscMetaConfiguration(msrest.serialization.Model): - """Definition of the DSC Meta Configuration. - - :param configuration_mode_frequency_mins: Gets or sets the ConfigurationModeFrequencyMins value - of the meta configuration. - :type configuration_mode_frequency_mins: int - :param reboot_node_if_needed: Gets or sets the RebootNodeIfNeeded value of the meta - configuration. - :type reboot_node_if_needed: bool - :param configuration_mode: Gets or sets the ConfigurationMode value of the meta configuration. - :type configuration_mode: str - :param action_after_reboot: Gets or sets the ActionAfterReboot value of the meta configuration. - :type action_after_reboot: str - :param certificate_id: Gets or sets the CertificateId value of the meta configuration. - :type certificate_id: str - :param refresh_frequency_mins: Gets or sets the RefreshFrequencyMins value of the meta - configuration. - :type refresh_frequency_mins: int - :param allow_module_overwrite: Gets or sets the AllowModuleOverwrite value of the meta - configuration. - :type allow_module_overwrite: bool - """ - - _attribute_map = { - 'configuration_mode_frequency_mins': {'key': 'configurationModeFrequencyMins', 'type': 'int'}, - 'reboot_node_if_needed': {'key': 'rebootNodeIfNeeded', 'type': 'bool'}, - 'configuration_mode': {'key': 'configurationMode', 'type': 'str'}, - 'action_after_reboot': {'key': 'actionAfterReboot', 'type': 'str'}, - 'certificate_id': {'key': 'certificateId', 'type': 'str'}, - 'refresh_frequency_mins': {'key': 'refreshFrequencyMins', 'type': 'int'}, - 'allow_module_overwrite': {'key': 'allowModuleOverwrite', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscMetaConfiguration, self).__init__(**kwargs) - self.configuration_mode_frequency_mins = kwargs.get('configuration_mode_frequency_mins', None) - self.reboot_node_if_needed = kwargs.get('reboot_node_if_needed', None) - self.configuration_mode = kwargs.get('configuration_mode', None) - self.action_after_reboot = kwargs.get('action_after_reboot', None) - self.certificate_id = kwargs.get('certificate_id', None) - self.refresh_frequency_mins = kwargs.get('refresh_frequency_mins', None) - self.allow_module_overwrite = kwargs.get('allow_module_overwrite', None) - - -class DscNode(Resource): - """Definition of a DscNode. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param last_seen: Gets or sets the last seen time of the node. - :type last_seen: ~datetime.datetime - :param registration_time: Gets or sets the registration time of the node. - :type registration_time: ~datetime.datetime - :param ip: Gets or sets the ip of the node. - :type ip: str - :param account_id: Gets or sets the account id of the node. - :type account_id: str - :param status: Gets or sets the status of the node. - :type status: str - :param node_id: Gets or sets the node id. - :type node_id: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param total_count: Gets the total number of records matching filter criteria. - :type total_count: int - :param extension_handler: Gets or sets the list of extensionHandler properties for a Node. - :type extension_handler: - list[~azure.mgmt.automation.models.DscNodeExtensionHandlerAssociationProperty] - :param name_properties_node_configuration_name: Gets or sets the name of the dsc node - configuration. - :type name_properties_node_configuration_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_seen': {'key': 'properties.lastSeen', 'type': 'iso-8601'}, - 'registration_time': {'key': 'properties.registrationTime', 'type': 'iso-8601'}, - 'ip': {'key': 'properties.ip', 'type': 'str'}, - 'account_id': {'key': 'properties.accountId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'node_id': {'key': 'properties.nodeId', 'type': 'str'}, - 'etag': {'key': 'properties.etag', 'type': 'str'}, - 'total_count': {'key': 'properties.totalCount', 'type': 'int'}, - 'extension_handler': {'key': 'properties.extensionHandler', 'type': '[DscNodeExtensionHandlerAssociationProperty]'}, - 'name_properties_node_configuration_name': {'key': 'properties.nodeConfiguration.name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNode, self).__init__(**kwargs) - self.last_seen = kwargs.get('last_seen', None) - self.registration_time = kwargs.get('registration_time', None) - self.ip = kwargs.get('ip', None) - self.account_id = kwargs.get('account_id', None) - self.status = kwargs.get('status', None) - self.node_id = kwargs.get('node_id', None) - self.etag = kwargs.get('etag', None) - self.total_count = kwargs.get('total_count', None) - self.extension_handler = kwargs.get('extension_handler', None) - self.name_properties_node_configuration_name = kwargs.get('name_properties_node_configuration_name', None) - - -class DscNodeConfiguration(Resource): - """Definition of the dsc node configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param creation_time: Gets or sets creation time. - :type creation_time: ~datetime.datetime - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param source: Source of node configuration. - :type source: str - :param node_count: Number of nodes with this node configuration assigned. - :type node_count: long - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'long'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfiguration, self).__init__(**kwargs) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.creation_time = kwargs.get('creation_time', None) - self.configuration = kwargs.get('configuration', None) - self.source = kwargs.get('source', None) - self.node_count = kwargs.get('node_count', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscNodeConfigurationCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update node configuration operation. - - :param name: Name of the node configuration. - :type name: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param source: Gets or sets the source. - :type source: ~azure.mgmt.automation.models.ContentSource - :param configuration: Gets or sets the configuration of the node. - :type configuration: ~azure.mgmt.automation.models.DscConfigurationAssociationProperty - :param increment_node_configuration_build: If a new build version of NodeConfiguration is - required. - :type increment_node_configuration_build: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'source': {'key': 'properties.source', 'type': 'ContentSource'}, - 'configuration': {'key': 'properties.configuration', 'type': 'DscConfigurationAssociationProperty'}, - 'increment_node_configuration_build': {'key': 'properties.incrementNodeConfigurationBuild', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfigurationCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tags = kwargs.get('tags', None) - self.source = kwargs.get('source', None) - self.configuration = kwargs.get('configuration', None) - self.increment_node_configuration_build = kwargs.get('increment_node_configuration_build', None) - - -class DscNodeConfigurationListResult(msrest.serialization.Model): - """The response model for the list job operation. - - :param value: Gets or sets a list of Dsc node configurations. - :type value: list[~azure.mgmt.automation.models.DscNodeConfiguration] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets or sets the total rows in query. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNodeConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscNodeExtensionHandlerAssociationProperty(msrest.serialization.Model): - """The dsc extensionHandler property associated with the node. - - :param name: Gets or sets the name of the extension handler. - :type name: str - :param version: Gets or sets the version of the extension handler. - :type version: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeExtensionHandlerAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.version = kwargs.get('version', None) - - -class DscNodeListResult(msrest.serialization.Model): - """The response model for the list dsc nodes operation. - - :param value: Gets or sets a list of dsc nodes. - :type value: list[~azure.mgmt.automation.models.DscNode] - :param next_link: Gets or sets the next link. - :type next_link: str - :param total_count: Gets the total number of nodes matching filter criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNode]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - self.total_count = kwargs.get('total_count', None) - - -class DscNodeReport(msrest.serialization.Model): - """Definition of the dsc node report type. - - :param end_time: Gets or sets the end time of the node report. - :type end_time: ~datetime.datetime - :param last_modified_time: Gets or sets the lastModifiedTime of the node report. - :type last_modified_time: ~datetime.datetime - :param start_time: Gets or sets the start time of the node report. - :type start_time: ~datetime.datetime - :param type: Gets or sets the type of the node report. - :type type: str - :param report_id: Gets or sets the id of the node report. - :type report_id: str - :param status: Gets or sets the status of the node report. - :type status: str - :param refresh_mode: Gets or sets the refreshMode of the node report. - :type refresh_mode: str - :param reboot_requested: Gets or sets the rebootRequested of the node report. - :type reboot_requested: str - :param report_format_version: Gets or sets the reportFormatVersion of the node report. - :type report_format_version: str - :param configuration_version: Gets or sets the configurationVersion of the node report. - :type configuration_version: str - :param id: Gets or sets the id. - :type id: str - :param errors: Gets or sets the errors for the node report. - :type errors: list[~azure.mgmt.automation.models.DscReportError] - :param resources: Gets or sets the resource for the node report. - :type resources: list[~azure.mgmt.automation.models.DscReportResource] - :param meta_configuration: Gets or sets the metaConfiguration of the node at the time of the - report. - :type meta_configuration: ~azure.mgmt.automation.models.DscMetaConfiguration - :param host_name: Gets or sets the hostname of the node that sent the report. - :type host_name: str - :param i_pv4_addresses: Gets or sets the IPv4 address of the node that sent the report. - :type i_pv4_addresses: list[str] - :param i_pv6_addresses: Gets or sets the IPv6 address of the node that sent the report. - :type i_pv6_addresses: list[str] - :param number_of_resources: Gets or sets the number of resource in the node report. - :type number_of_resources: int - :param raw_errors: Gets or sets the unparsed errors for the node report. - :type raw_errors: str - """ - - _attribute_map = { - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'type': {'key': 'type', 'type': 'str'}, - 'report_id': {'key': 'reportId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'refresh_mode': {'key': 'refreshMode', 'type': 'str'}, - 'reboot_requested': {'key': 'rebootRequested', 'type': 'str'}, - 'report_format_version': {'key': 'reportFormatVersion', 'type': 'str'}, - 'configuration_version': {'key': 'configurationVersion', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[DscReportError]'}, - 'resources': {'key': 'resources', 'type': '[DscReportResource]'}, - 'meta_configuration': {'key': 'metaConfiguration', 'type': 'DscMetaConfiguration'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'i_pv4_addresses': {'key': 'iPV4Addresses', 'type': '[str]'}, - 'i_pv6_addresses': {'key': 'iPV6Addresses', 'type': '[str]'}, - 'number_of_resources': {'key': 'numberOfResources', 'type': 'int'}, - 'raw_errors': {'key': 'rawErrors', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeReport, self).__init__(**kwargs) - self.end_time = kwargs.get('end_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.start_time = kwargs.get('start_time', None) - self.type = kwargs.get('type', None) - self.report_id = kwargs.get('report_id', None) - self.status = kwargs.get('status', None) - self.refresh_mode = kwargs.get('refresh_mode', None) - self.reboot_requested = kwargs.get('reboot_requested', None) - self.report_format_version = kwargs.get('report_format_version', None) - self.configuration_version = kwargs.get('configuration_version', None) - self.id = kwargs.get('id', None) - self.errors = kwargs.get('errors', None) - self.resources = kwargs.get('resources', None) - self.meta_configuration = kwargs.get('meta_configuration', None) - self.host_name = kwargs.get('host_name', None) - self.i_pv4_addresses = kwargs.get('i_pv4_addresses', None) - self.i_pv6_addresses = kwargs.get('i_pv6_addresses', None) - self.number_of_resources = kwargs.get('number_of_resources', None) - self.raw_errors = kwargs.get('raw_errors', None) - - -class DscNodeReportListResult(msrest.serialization.Model): - """The response model for the list dsc nodes operation. - - :param value: Gets or sets a list of dsc node reports. - :type value: list[~azure.mgmt.automation.models.DscNodeReport] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DscNodeReport]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeReportListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DscNodeUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update dsc node operation. - - :param node_id: Gets or sets the id of the dsc node. - :type node_id: str - :param properties: - :type properties: ~azure.mgmt.automation.models.DscNodeUpdateParametersProperties - """ - - _attribute_map = { - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DscNodeUpdateParametersProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeUpdateParameters, self).__init__(**kwargs) - self.node_id = kwargs.get('node_id', None) - self.properties = kwargs.get('properties', None) - - -class DscNodeUpdateParametersProperties(msrest.serialization.Model): - """DscNodeUpdateParametersProperties. - - :param name: Gets or sets the name of the dsc node configuration. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'nodeConfiguration.name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscNodeUpdateParametersProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class DscReportError(msrest.serialization.Model): - """Definition of the dsc node report error type. - - :param error_source: Gets or sets the source of the error. - :type error_source: str - :param resource_id: Gets or sets the resource ID which generated the error. - :type resource_id: str - :param error_code: Gets or sets the error code. - :type error_code: str - :param error_message: Gets or sets the error message. - :type error_message: str - :param locale: Gets or sets the locale of the error. - :type locale: str - :param error_details: Gets or sets the error details. - :type error_details: str - """ - - _attribute_map = { - 'error_source': {'key': 'errorSource', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'locale': {'key': 'locale', 'type': 'str'}, - 'error_details': {'key': 'errorDetails', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportError, self).__init__(**kwargs) - self.error_source = kwargs.get('error_source', None) - self.resource_id = kwargs.get('resource_id', None) - self.error_code = kwargs.get('error_code', None) - self.error_message = kwargs.get('error_message', None) - self.locale = kwargs.get('locale', None) - self.error_details = kwargs.get('error_details', None) - - -class DscReportResource(msrest.serialization.Model): - """Definition of the DSC Report Resource. - - :param resource_id: Gets or sets the ID of the resource. - :type resource_id: str - :param source_info: Gets or sets the source info of the resource. - :type source_info: str - :param depends_on: Gets or sets the Resource Navigation values for resources the resource - depends on. - :type depends_on: list[~azure.mgmt.automation.models.DscReportResourceNavigation] - :param module_name: Gets or sets the module name of the resource. - :type module_name: str - :param module_version: Gets or sets the module version of the resource. - :type module_version: str - :param resource_name: Gets or sets the name of the resource. - :type resource_name: str - :param error: Gets or sets the error of the resource. - :type error: str - :param status: Gets or sets the status of the resource. - :type status: str - :param duration_in_seconds: Gets or sets the duration in seconds for the resource. - :type duration_in_seconds: float - :param start_date: Gets or sets the start date of the resource. - :type start_date: ~datetime.datetime - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'source_info': {'key': 'sourceInfo', 'type': 'str'}, - 'depends_on': {'key': 'dependsOn', 'type': '[DscReportResourceNavigation]'}, - 'module_name': {'key': 'moduleName', 'type': 'str'}, - 'module_version': {'key': 'moduleVersion', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'duration_in_seconds': {'key': 'durationInSeconds', 'type': 'float'}, - 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportResource, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.source_info = kwargs.get('source_info', None) - self.depends_on = kwargs.get('depends_on', None) - self.module_name = kwargs.get('module_name', None) - self.module_version = kwargs.get('module_version', None) - self.resource_name = kwargs.get('resource_name', None) - self.error = kwargs.get('error', None) - self.status = kwargs.get('status', None) - self.duration_in_seconds = kwargs.get('duration_in_seconds', None) - self.start_date = kwargs.get('start_date', None) - - -class DscReportResourceNavigation(msrest.serialization.Model): - """Navigation for DSC Report Resource. - - :param resource_id: Gets or sets the ID of the resource to navigate to. - :type resource_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DscReportResourceNavigation, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response of an operation failure. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class FieldDefinition(msrest.serialization.Model): - """Definition of the connection fields. - - All required parameters must be populated in order to send to Azure. - - :param is_encrypted: Gets or sets the isEncrypted flag of the connection field definition. - :type is_encrypted: bool - :param is_optional: Gets or sets the isOptional flag of the connection field definition. - :type is_optional: bool - :param type: Required. Gets or sets the type of the connection field definition. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'is_encrypted': {'key': 'isEncrypted', 'type': 'bool'}, - 'is_optional': {'key': 'isOptional', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FieldDefinition, self).__init__(**kwargs) - self.is_encrypted = kwargs.get('is_encrypted', None) - self.is_optional = kwargs.get('is_optional', None) - self.type = kwargs['type'] - - -class HybridRunbookWorker(msrest.serialization.Model): - """Definition of hybrid runbook worker. - - :param name: Gets or sets the worker machine name. - :type name: str - :param ip: Gets or sets the assigned machine IP address. - :type ip: str - :param registration_time: Gets or sets the registration time of the worker machine. - :type registration_time: ~datetime.datetime - :param last_seen_date_time: Last Heartbeat from the Worker. - :type last_seen_date_time: ~datetime.datetime - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'ip': {'key': 'ip', 'type': 'str'}, - 'registration_time': {'key': 'registrationTime', 'type': 'iso-8601'}, - 'last_seen_date_time': {'key': 'lastSeenDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorker, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.ip = kwargs.get('ip', None) - self.registration_time = kwargs.get('registration_time', None) - self.last_seen_date_time = kwargs.get('last_seen_date_time', None) - - -class HybridRunbookWorkerGroup(msrest.serialization.Model): - """Definition of hybrid runbook worker group. - - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the name of the group. - :type name: str - :param hybrid_runbook_workers: Gets or sets the list of hybrid runbook workers. - :type hybrid_runbook_workers: list[~azure.mgmt.automation.models.HybridRunbookWorker] - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty - :param group_type: Type of the HybridWorkerGroup. Possible values include: "User", "System". - :type group_type: str or ~azure.mgmt.automation.models.GroupTypeEnum - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'hybrid_runbook_workers': {'key': 'hybridRunbookWorkers', 'type': '[HybridRunbookWorker]'}, - 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, - 'group_type': {'key': 'groupType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroup, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.hybrid_runbook_workers = kwargs.get('hybrid_runbook_workers', None) - self.credential = kwargs.get('credential', None) - self.group_type = kwargs.get('group_type', None) - - -class HybridRunbookWorkerGroupsListResult(msrest.serialization.Model): - """The response model for the list hybrid runbook worker groups. - - :param value: Gets or sets a list of hybrid runbook worker groups. - :type value: list[~azure.mgmt.automation.models.HybridRunbookWorkerGroup] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HybridRunbookWorkerGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class HybridRunbookWorkerGroupUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the update operation. - - :param credential: Sets the credential of a worker group. - :type credential: ~azure.mgmt.automation.models.RunAsCredentialAssociationProperty - """ - - _attribute_map = { - 'credential': {'key': 'credential', 'type': 'RunAsCredentialAssociationProperty'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridRunbookWorkerGroupUpdateParameters, self).__init__(**kwargs) - self.credential = kwargs.get('credential', None) - - -class Job(Resource): - """Definition of the job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param started_by: Gets or sets the job started by. - :type started_by: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param job_id: Gets or sets the id of the job. - :type job_id: str - :param creation_time: Gets or sets the creation time of the job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the job. Possible values include: "New", - "Activating", "Running", "Completed", "Failed", "Stopped", "Blocked", "Suspended", - "Disconnected", "Suspending", "Stopping", "Resuming", "Removing". - :type status: str or ~azure.mgmt.automation.models.JobStatus - :param status_details: Gets or sets the status details of the job. - :type status_details: str - :param start_time: Gets or sets the start time of the job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param provisioning_state: The current provisioning state of the job. Possible values include: - "Failed", "Succeeded", "Suspended", "Processing". - :type provisioning_state: str or ~azure.mgmt.automation.models.JobProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'started_by': {'key': 'properties.startedBy', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_details': {'key': 'properties.statusDetails', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'properties.lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.runbook = kwargs.get('runbook', None) - self.started_by = kwargs.get('started_by', None) - self.run_on = kwargs.get('run_on', None) - self.job_id = kwargs.get('job_id', None) - self.creation_time = kwargs.get('creation_time', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.exception = kwargs.get('exception', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_status_modified_time = kwargs.get('last_status_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class JobCollectionItem(Resource): - """Job collection item properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar runbook: The runbook association. - :vartype runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :ivar job_id: The id of the job. - :vartype job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :ivar status: The status of the job. Possible values include: "New", "Activating", "Running", - "Completed", "Failed", "Stopped", "Blocked", "Suspended", "Disconnected", "Suspending", - "Stopping", "Resuming", "Removing". - :vartype status: str or ~azure.mgmt.automation.models.JobStatus - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :ivar last_modified_time: The last modified time of the job. - :vartype last_modified_time: ~datetime.datetime - :ivar provisioning_state: The provisioning state of a resource. - :vartype provisioning_state: str - :param run_on: Specifies the runOn group name where the job was executed. - :type run_on: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'runbook': {'readonly': True}, - 'job_id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'job_id': {'key': 'properties.jobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCollectionItem, self).__init__(**kwargs) - self.runbook = None - self.job_id = None - self.creation_time = None - self.status = None - self.start_time = None - self.end_time = None - self.last_modified_time = None - self.provisioning_state = None - self.run_on = kwargs.get('run_on', None) - - -class JobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create job operation. - - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - """ - - _attribute_map = { - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobCreateParameters, self).__init__(**kwargs) - self.runbook = kwargs.get('runbook', None) - self.parameters = kwargs.get('parameters', None) - self.run_on = kwargs.get('run_on', None) - - -class JobListResultV2(msrest.serialization.Model): - """The response model for the list job operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of jobs. - :type value: list[~azure.mgmt.automation.models.JobCollectionItem] - :ivar next_link: The link to the next page. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobCollectionItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobListResultV2, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class JobNavigation(msrest.serialization.Model): - """Software update configuration machine run job navigation properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the job associated with the software update configuration run. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobNavigation, self).__init__(**kwargs) - self.id = None - - -class JobSchedule(msrest.serialization.Model): - """Definition of the job schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the resource. - :vartype id: str - :ivar name: Gets the name of the variable. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param job_schedule_id: Gets or sets the id of job schedule. - :type job_schedule_id: str - :param schedule: Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job schedule. - :type parameters: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'job_schedule_id': {'key': 'properties.jobScheduleId', 'type': 'str'}, - 'schedule': {'key': 'properties.schedule', 'type': 'ScheduleAssociationProperty'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobSchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.job_schedule_id = kwargs.get('job_schedule_id', None) - self.schedule = kwargs.get('schedule', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - - -class JobScheduleCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create job schedule operation. - - All required parameters must be populated in order to send to Azure. - - :param schedule: Required. Gets or sets the schedule. - :type schedule: ~azure.mgmt.automation.models.ScheduleAssociationProperty - :param runbook: Required. Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the hybrid worker group that the scheduled job should run on. - :type run_on: str - :param parameters: Gets or sets a list of job properties. - :type parameters: dict[str, str] - """ - - _validation = { - 'schedule': {'required': True}, - 'runbook': {'required': True}, - } - - _attribute_map = { - 'schedule': {'key': 'properties.schedule', 'type': 'ScheduleAssociationProperty'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobScheduleCreateParameters, self).__init__(**kwargs) - self.schedule = kwargs['schedule'] - self.runbook = kwargs['runbook'] - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - - -class JobScheduleListResult(msrest.serialization.Model): - """The response model for the list job schedule operation. - - :param value: Gets or sets a list of job schedules. - :type value: list[~azure.mgmt.automation.models.JobSchedule] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class JobStream(msrest.serialization.Model): - """Definition of the job stream. - - :param id: Gets or sets the id of the resource. - :type id: str - :param job_stream_id: Gets or sets the id of the job stream. - :type job_stream_id: str - :param time: Gets or sets the creation time of the job. - :type time: ~datetime.datetime - :param stream_type: Gets or sets the stream type. Possible values include: "Progress", - "Output", "Warning", "Error", "Debug", "Verbose", "Any". - :type stream_type: str or ~azure.mgmt.automation.models.JobStreamType - :param stream_text: Gets or sets the stream text. - :type stream_text: str - :param summary: Gets or sets the summary. - :type summary: str - :param value: Gets or sets the values of the job stream. - :type value: dict[str, object] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'job_stream_id': {'key': 'properties.jobStreamId', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - 'stream_text': {'key': 'properties.streamText', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStream, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.job_stream_id = kwargs.get('job_stream_id', None) - self.time = kwargs.get('time', None) - self.stream_type = kwargs.get('stream_type', None) - self.stream_text = kwargs.get('stream_text', None) - self.summary = kwargs.get('summary', None) - self.value = kwargs.get('value', None) - - -class JobStreamListResult(msrest.serialization.Model): - """The response model for the list job stream operation. - - :param value: A list of job streams. - :type value: list[~azure.mgmt.automation.models.JobStream] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[JobStream]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobStreamListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Key(msrest.serialization.Model): - """Automation key which is used to register a DSC Node. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar key_name: Automation key name. Possible values include: "Primary", "Secondary". - :vartype key_name: str or ~azure.mgmt.automation.models.AutomationKeyName - :ivar permissions: Automation key permissions. Possible values include: "Read", "Full". - :vartype permissions: str or ~azure.mgmt.automation.models.AutomationKeyPermissions - :ivar value: Value of the Automation Key used for registration. - :vartype value: str - """ - - _validation = { - 'key_name': {'readonly': True}, - 'permissions': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'key_name': {'key': 'KeyName', 'type': 'str'}, - 'permissions': {'key': 'Permissions', 'type': 'str'}, - 'value': {'key': 'Value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Key, self).__init__(**kwargs) - self.key_name = None - self.permissions = None - self.value = None - - -class KeyListResult(msrest.serialization.Model): - """KeyListResult. - - :param keys: Lists the automation keys. - :type keys: list[~azure.mgmt.automation.models.Key] - """ - - _attribute_map = { - 'keys': {'key': 'keys', 'type': '[Key]'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyListResult, self).__init__(**kwargs) - self.keys = kwargs.get('keys', None) - - -class LinkedWorkspace(msrest.serialization.Model): - """Definition of the linked workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Gets the id of the linked workspace. - :vartype id: str - """ - - _validation = { - 'id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinkedWorkspace, self).__init__(**kwargs) - self.id = None - - -class LinuxProperties(msrest.serialization.Model): - """Linux specific update configuration. - - :param included_package_classifications: Update classifications included in the software update - configuration. Possible values include: "Unclassified", "Critical", "Security", "Other". - :type included_package_classifications: str or ~azure.mgmt.automation.models.LinuxUpdateClasses - :param excluded_package_name_masks: packages excluded from the software update configuration. - :type excluded_package_name_masks: list[str] - :param included_package_name_masks: packages included from the software update configuration. - :type included_package_name_masks: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str - """ - - _attribute_map = { - 'included_package_classifications': {'key': 'includedPackageClassifications', 'type': 'str'}, - 'excluded_package_name_masks': {'key': 'excludedPackageNameMasks', 'type': '[str]'}, - 'included_package_name_masks': {'key': 'includedPackageNameMasks', 'type': '[str]'}, - 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxProperties, self).__init__(**kwargs) - self.included_package_classifications = kwargs.get('included_package_classifications', None) - self.excluded_package_name_masks = kwargs.get('excluded_package_name_masks', None) - self.included_package_name_masks = kwargs.get('included_package_name_masks', None) - self.reboot_setting = kwargs.get('reboot_setting', None) - - -class Module(TrackedResource): - """Definition of the module type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param is_global: Gets or sets the isGlobal flag of the module. - :type is_global: bool - :param version: Gets or sets the version of the module. - :type version: str - :param size_in_bytes: Gets or sets the size in bytes of the module. - :type size_in_bytes: long - :param activity_count: Gets or sets the activity count of the module. - :type activity_count: int - :param provisioning_state: Gets or sets the provisioning state of the module. Possible values - include: "Created", "Creating", "StartingImportModuleRunbook", "RunningImportModuleRunbook", - "ContentRetrieved", "ContentDownloaded", "ContentValidated", "ConnectionTypeImported", - "ContentStored", "ModuleDataStored", "ActivitiesStored", "ModuleImportRunbookComplete", - "Succeeded", "Failed", "Cancelled", "Updating". - :type provisioning_state: str or ~azure.mgmt.automation.models.ModuleProvisioningState - :param content_link: Gets or sets the contentLink of the module. - :type content_link: ~azure.mgmt.automation.models.ContentLink - :param error: Gets or sets the error info of the module. - :type error: ~azure.mgmt.automation.models.ModuleErrorInfo - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - :param is_composite: Gets or sets type of module, if its composite or not. - :type is_composite: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'is_global': {'key': 'properties.isGlobal', 'type': 'bool'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'activity_count': {'key': 'properties.activityCount', 'type': 'int'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - 'error': {'key': 'properties.error', 'type': 'ModuleErrorInfo'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_composite': {'key': 'properties.isComposite', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Module, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.is_global = kwargs.get('is_global', None) - self.version = kwargs.get('version', None) - self.size_in_bytes = kwargs.get('size_in_bytes', None) - self.activity_count = kwargs.get('activity_count', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.content_link = kwargs.get('content_link', None) - self.error = kwargs.get('error', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - self.is_composite = kwargs.get('is_composite', None) - - -class ModuleCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update module operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _validation = { - 'content_link': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs['content_link'] - - -class ModuleErrorInfo(msrest.serialization.Model): - """Definition of the module error info type. - - :param code: Gets or sets the error code. - :type code: str - :param message: Gets or sets the error message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleErrorInfo, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ModuleListResult(msrest.serialization.Model): - """The response model for the list module operation. - - :param value: Gets or sets a list of modules. - :type value: list[~azure.mgmt.automation.models.Module] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Module]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ModuleUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update module operation. - - :param name: Gets or sets name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(ModuleUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs.get('content_link', None) - - -class NodeCount(msrest.serialization.Model): - """Number of nodes based on the Filter. - - :param name: Gets the name of a count type. - :type name: str - :param properties: - :type properties: ~azure.mgmt.automation.models.NodeCountProperties - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'NodeCountProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCount, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.properties = kwargs.get('properties', None) - - -class NodeCountProperties(msrest.serialization.Model): - """NodeCountProperties. - - :param count: Gets the count for the name. - :type count: int - """ - - _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCountProperties, self).__init__(**kwargs) - self.count = kwargs.get('count', None) - - -class NodeCounts(msrest.serialization.Model): - """Gets the count of nodes by count type. - - :param value: Gets an array of counts. - :type value: list[~azure.mgmt.automation.models.NodeCount] - :param total_count: Gets the total number of records matching countType criteria. - :type total_count: int - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NodeCount]'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeCounts, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.total_count = kwargs.get('total_count', None) - - -class NonAzureQueryProperties(msrest.serialization.Model): - """Non Azure query for the update configuration. - - :param function_alias: Log Analytics Saved Search name. - :type function_alias: str - :param workspace_id: Workspace Id for Log Analytics in which the saved Search is resided. - :type workspace_id: str - """ - - _attribute_map = { - 'function_alias': {'key': 'functionAlias', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NonAzureQueryProperties, self).__init__(**kwargs) - self.function_alias = kwargs.get('function_alias', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -class Operation(msrest.serialization.Model): - """Automation REST API operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Provider, Resource and Operation values. - :type display: ~azure.mgmt.automation.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Provider, Resource and Operation values. - - :param provider: Service provider: Microsoft.Automation. - :type provider: str - :param resource: Resource on which the operation is performed: Runbooks, Jobs etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -class OperationListResult(msrest.serialization.Model): - """The response model for the list of Automation operations. - - :param value: List of Automation operations supported by the Automation resource provider. - :type value: list[~azure.mgmt.automation.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ProxyResource(Resource): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class PythonPackageCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update module operation. - - All required parameters must be populated in order to send to Azure. - - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink - """ - - _validation = { - 'content_link': {'required': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, - } - - def __init__( - self, - **kwargs - ): - super(PythonPackageCreateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.content_link = kwargs['content_link'] - - -class PythonPackageUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update module operation. - - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(PythonPackageUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class RunAsCredentialAssociationProperty(msrest.serialization.Model): - """Definition of RunAs credential to use for hybrid worker. - - :param name: Gets or sets the name of the credential. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunAsCredentialAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class Runbook(TrackedResource): - """Definition of the runbook type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param runbook_type: Gets or sets the type of the runbook. Possible values include: "Script", - "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param state: Gets or sets the state of the runbook. Possible values include: "New", "Edit", - "Published". - :type state: str or ~azure.mgmt.automation.models.RunbookState - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the option to log activity trace of the runbook. - :type log_activity_trace: int - :param job_count: Gets or sets the job count of the runbook. - :type job_count: int - :param parameters: Gets or sets the runbook parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :ivar provisioning_state: Gets or sets the provisioning state of the runbook. Default value: - "Succeeded". - :vartype provisioning_state: str - :param last_modified_by: Gets or sets the last modified by. - :type last_modified_by: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'runbook_type': {'key': 'properties.runbookType', 'type': 'str'}, - 'publish_content_link': {'key': 'properties.publishContentLink', 'type': 'ContentLink'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - 'job_count': {'key': 'properties.jobCount', 'type': 'int'}, - 'parameters': {'key': 'properties.parameters', 'type': '{RunbookParameter}'}, - 'output_types': {'key': 'properties.outputTypes', 'type': '[str]'}, - 'draft': {'key': 'properties.draft', 'type': 'RunbookDraft'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - provisioning_state = "Succeeded" - - def __init__( - self, - **kwargs - ): - super(Runbook, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.runbook_type = kwargs.get('runbook_type', None) - self.publish_content_link = kwargs.get('publish_content_link', None) - self.state = kwargs.get('state', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - self.job_count = kwargs.get('job_count', None) - self.parameters = kwargs.get('parameters', None) - self.output_types = kwargs.get('output_types', None) - self.draft = kwargs.get('draft', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class RunbookAssociationProperty(msrest.serialization.Model): - """The runbook property associated with the entity. - - :param name: Gets or sets the name of the runbook. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class RunbookCreateOrUpdateDraftParameters(msrest.serialization.Model): - """The parameters supplied to the create or update runbook operation. - - All required parameters must be populated in order to send to Azure. - - :param runbook_content: Required. Content of the Runbook. - :type runbook_content: str - """ - - _validation = { - 'runbook_content': {'required': True}, - } - - _attribute_map = { - 'runbook_content': {'key': 'runbookContent', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateDraftParameters, self).__init__(**kwargs) - self.runbook_content = kwargs['runbook_content'] - - -class RunbookCreateOrUpdateDraftProperties(msrest.serialization.Model): - """The parameters supplied to the create or update draft runbook properties. - - All required parameters must be populated in order to send to Azure. - - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Required. Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _validation = { - 'runbook_type': {'required': True}, - 'draft': {'required': True}, - } - - _attribute_map = { - 'log_verbose': {'key': 'logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'logProgress', 'type': 'bool'}, - 'runbook_type': {'key': 'runbookType', 'type': 'str'}, - 'draft': {'key': 'draft', 'type': 'RunbookDraft'}, - 'description': {'key': 'description', 'type': 'str'}, - 'log_activity_trace': {'key': 'logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateDraftProperties, self).__init__(**kwargs) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.runbook_type = kwargs['runbook_type'] - self.draft = kwargs['draft'] - self.description = kwargs.get('description', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class RunbookCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update runbook operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: - "Script", "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", - "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param draft: Gets or sets the draft runbook properties. - :type draft: ~azure.mgmt.automation.models.RunbookDraft - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _validation = { - 'runbook_type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'runbook_type': {'key': 'properties.runbookType', 'type': 'str'}, - 'draft': {'key': 'properties.draft', 'type': 'RunbookDraft'}, - 'publish_content_link': {'key': 'properties.publishContentLink', 'type': 'ContentLink'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.runbook_type = kwargs['runbook_type'] - self.draft = kwargs.get('draft', None) - self.publish_content_link = kwargs.get('publish_content_link', None) - self.description = kwargs.get('description', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class RunbookDraft(msrest.serialization.Model): - """RunbookDraft. - - :param in_edit: Gets or sets whether runbook is in edit mode. - :type in_edit: bool - :param draft_content_link: Gets or sets the draft runbook content link. - :type draft_content_link: ~azure.mgmt.automation.models.ContentLink - :param creation_time: Gets or sets the creation time of the runbook draft. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time of the runbook draft. - :type last_modified_time: ~datetime.datetime - :param parameters: Gets or sets the runbook draft parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] - """ - - _attribute_map = { - 'in_edit': {'key': 'inEdit', 'type': 'bool'}, - 'draft_content_link': {'key': 'draftContentLink', 'type': 'ContentLink'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'parameters', 'type': '{RunbookParameter}'}, - 'output_types': {'key': 'outputTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookDraft, self).__init__(**kwargs) - self.in_edit = kwargs.get('in_edit', None) - self.draft_content_link = kwargs.get('draft_content_link', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.output_types = kwargs.get('output_types', None) - - -class RunbookDraftUndoEditResult(msrest.serialization.Model): - """The response model for the undo edit runbook operation. - - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", - "HttpVersionNotSupported". - :type status_code: str or ~azure.mgmt.automation.models.HttpStatusCode - :param request_id: - :type request_id: str - """ - - _attribute_map = { - 'status_code': {'key': 'statusCode', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookDraftUndoEditResult, self).__init__(**kwargs) - self.status_code = kwargs.get('status_code', None) - self.request_id = kwargs.get('request_id', None) - - -class RunbookListResult(msrest.serialization.Model): - """The response model for the list runbook operation. - - :param value: Gets or sets a list of runbooks. - :type value: list[~azure.mgmt.automation.models.Runbook] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Runbook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RunbookParameter(msrest.serialization.Model): - """Definition of the runbook parameter type. - - :param type: Gets or sets the type of the parameter. - :type type: str - :param is_mandatory: Gets or sets a Boolean value to indicate whether the parameter is - mandatory or not. - :type is_mandatory: bool - :param position: Get or sets the position of the parameter. - :type position: int - :param default_value: Gets or sets the default value of parameter. - :type default_value: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'is_mandatory': {'key': 'isMandatory', 'type': 'bool'}, - 'position': {'key': 'position', 'type': 'int'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookParameter, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.is_mandatory = kwargs.get('is_mandatory', None) - self.position = kwargs.get('position', None) - self.default_value = kwargs.get('default_value', None) - - -class RunbookUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update runbook operation. - - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param description: Gets or sets the description of the runbook. - :type description: str - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param log_activity_trace: Gets or sets the activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, - 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, - 'log_activity_trace': {'key': 'properties.logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RunbookUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.log_verbose = kwargs.get('log_verbose', None) - self.log_progress = kwargs.get('log_progress', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class Schedule(Resource): - """Definition of the schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :ivar start_time_offset_minutes: Gets the start time's offset in minutes. - :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start_time_offset_minutes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'start_time_offset_minutes': {'key': 'properties.startTimeOffsetMinutes', 'type': 'float'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'expiry_time_offset_minutes': {'key': 'properties.expiryTimeOffsetMinutes', 'type': 'float'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'next_run': {'key': 'properties.nextRun', 'type': 'iso-8601'}, - 'next_run_offset_minutes': {'key': 'properties.nextRunOffsetMinutes', 'type': 'float'}, - 'interval': {'key': 'properties.interval', 'type': 'object'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'properties.advancedSchedule', 'type': 'AdvancedSchedule'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Schedule, self).__init__(**kwargs) - self.start_time = kwargs.get('start_time', None) - self.start_time_offset_minutes = None - self.expiry_time = kwargs.get('expiry_time', None) - self.expiry_time_offset_minutes = kwargs.get('expiry_time_offset_minutes', None) - self.is_enabled = kwargs.get('is_enabled', False) - self.next_run = kwargs.get('next_run', None) - self.next_run_offset_minutes = kwargs.get('next_run_offset_minutes', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs.get('frequency', None) - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class ScheduleAssociationProperty(msrest.serialization.Model): - """The schedule property associated with the entity. - - :param name: Gets or sets the name of the Schedule. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleAssociationProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ScheduleCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update schedule operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param start_time: Required. Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param interval: Gets or sets the interval of the schedule. - :type interval: object - :param frequency: Required. Gets or sets the frequency of the schedule. Possible values - include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the AdvancedSchedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - """ - - _validation = { - 'name': {'required': True}, - 'start_time': {'required': True}, - 'frequency': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'interval': {'key': 'properties.interval', 'type': 'object'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'properties.advancedSchedule', 'type': 'AdvancedSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.description = kwargs.get('description', None) - self.start_time = kwargs['start_time'] - self.expiry_time = kwargs.get('expiry_time', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs['frequency'] - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - - -class ScheduleListResult(msrest.serialization.Model): - """The response model for the list schedule operation. - - :param value: Gets or sets a list of schedules. - :type value: list[~azure.mgmt.automation.models.Schedule] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Schedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ScheduleUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update schedule operation. - - :param name: Gets or sets the name of the Schedule. - :type name: str - :param description: Gets or sets the description of the schedule. - :type description: str - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduleUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.is_enabled = kwargs.get('is_enabled', None) - - -class Sku(msrest.serialization.Model): - """The account SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the SKU name of the account. Possible values include: - "Free", "Basic". - :type name: str or ~azure.mgmt.automation.models.SkuNameEnum - :param family: Gets or sets the SKU family. - :type family: str - :param capacity: Gets or sets the SKU capacity. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.family = kwargs.get('family', None) - self.capacity = kwargs.get('capacity', None) - - -class SoftwareUpdateConfiguration(msrest.serialization.Model): - """Software update configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Resource name. - :vartype name: str - :ivar id: Resource Id. - :vartype id: str - :ivar type: Resource type. - :vartype type: str - :param update_configuration: Required. update specific properties for the Software update - configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param schedule_info: Required. Schedule information for the Software update configuration. - :type schedule_info: ~azure.mgmt.automation.models.SUCScheduleProperties - :ivar provisioning_state: Provisioning state for the software update configuration, which only - appears in the response. - :vartype provisioning_state: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: CreatedBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: LastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param tasks: Tasks information for the Software update configuration. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'update_configuration': {'required': True}, - 'schedule_info': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'update_configuration': {'key': 'properties.updateConfiguration', 'type': 'UpdateConfiguration'}, - 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'SUCScheduleProperties'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponse'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationTasks'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfiguration, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - self.update_configuration = kwargs['update_configuration'] - self.schedule_info = kwargs['schedule_info'] - self.provisioning_state = None - self.error = kwargs.get('error', None) - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.tasks = kwargs.get('tasks', None) - - -class SoftwareUpdateConfigurationCollectionItem(msrest.serialization.Model): - """Software update configuration collection item properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration. - :vartype name: str - :ivar id: Resource Id of the software update configuration. - :vartype id: str - :param update_configuration: Update specific properties of the software update configuration. - :type update_configuration: ~azure.mgmt.automation.models.UpdateConfiguration - :param tasks: Pre and Post Tasks defined. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationTasks - :param frequency: execution frequency of the schedule associated with the software update - configuration. Possible values include: "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param start_time: the start time of the update. - :type start_time: ~datetime.datetime - :ivar creation_time: Creation time of the software update configuration, which only appears in - the response. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Last time software update configuration was modified, which only - appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar provisioning_state: Provisioning state for the software update configuration, which only - appears in the response. - :vartype provisioning_state: str - :param next_run: ext run time of the update. - :type next_run: ~datetime.datetime - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'update_configuration': {'key': 'properties.updateConfiguration', 'type': 'UpdateConfiguration'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationTasks'}, - 'frequency': {'key': 'properties.frequency', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'next_run': {'key': 'properties.nextRun', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationCollectionItem, self).__init__(**kwargs) - self.name = None - self.id = None - self.update_configuration = kwargs.get('update_configuration', None) - self.tasks = kwargs.get('tasks', None) - self.frequency = kwargs.get('frequency', None) - self.start_time = kwargs.get('start_time', None) - self.creation_time = None - self.last_modified_time = None - self.provisioning_state = None - self.next_run = kwargs.get('next_run', None) - - -class SoftwareUpdateConfigurationListResult(msrest.serialization.Model): - """result of listing all software update configuration. - - :param value: outer object returned when listing all software update configurations. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationCollectionItem] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationCollectionItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SoftwareUpdateConfigurationMachineRun(msrest.serialization.Model): - """Software update configuration machine run model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration machine run. - :vartype name: str - :ivar id: Resource Id of the software update configuration machine run. - :vartype id: str - :ivar target_computer: name of the updated computer. - :vartype target_computer: str - :ivar target_computer_type: type of the updated computer. - :vartype target_computer_type: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: - ~azure.mgmt.automation.models.UpdateConfigurationNavigation - :ivar status: Status of the software update configuration machine run. - :vartype status: str - :ivar os_type: Operating system target of the software update configuration triggered this run. - :vartype os_type: str - :ivar correlation_id: correlation id of the software update configuration machine run. - :vartype correlation_id: str - :ivar source_computer_id: source computer id of the software update configuration machine run. - :vartype source_computer_id: str - :ivar start_time: Start time of the software update configuration machine run. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the software update configuration machine run. - :vartype end_time: ~datetime.datetime - :ivar configured_duration: configured duration for the software update configuration run. - :vartype configured_duration: str - :param job: Job associated with the software update configuration machine run. - :type job: ~azure.mgmt.automation.models.JobNavigation - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: createdBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: lastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param error: Details of provisioning error. - :type error: ~azure.mgmt.automation.models.ErrorResponse - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'target_computer': {'readonly': True}, - 'target_computer_type': {'readonly': True}, - 'status': {'readonly': True}, - 'os_type': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'source_computer_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'configured_duration': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'target_computer': {'key': 'properties.targetComputer', 'type': 'str'}, - 'target_computer_type': {'key': 'properties.targetComputerType', 'type': 'str'}, - 'software_update_configuration': {'key': 'properties.softwareUpdateConfiguration', 'type': 'UpdateConfigurationNavigation'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'correlation_id': {'key': 'properties.correlationId', 'type': 'str'}, - 'source_computer_id': {'key': 'properties.sourceComputerId', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'configured_duration': {'key': 'properties.configuredDuration', 'type': 'str'}, - 'job': {'key': 'properties.job', 'type': 'JobNavigation'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationMachineRun, self).__init__(**kwargs) - self.name = None - self.id = None - self.target_computer = None - self.target_computer_type = None - self.software_update_configuration = kwargs.get('software_update_configuration', None) - self.status = None - self.os_type = None - self.correlation_id = None - self.source_computer_id = None - self.start_time = None - self.end_time = None - self.configured_duration = None - self.job = kwargs.get('job', None) - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.error = kwargs.get('error', None) - - -class SoftwareUpdateConfigurationMachineRunListResult(msrest.serialization.Model): - """result of listing all software update configuration machine runs. - - :param value: outer object returned when listing all software update configuration machine - runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun] - :param next_link: link to next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationMachineRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationMachineRunListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SoftwareUpdateConfigurationRun(msrest.serialization.Model): - """Software update configuration Run properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration run. - :vartype name: str - :ivar id: Resource Id of the software update configuration run. - :vartype id: str - :param software_update_configuration: software update configuration triggered this run. - :type software_update_configuration: - ~azure.mgmt.automation.models.UpdateConfigurationNavigation - :ivar status: Status of the software update configuration run. - :vartype status: str - :ivar configured_duration: Configured duration for the software update configuration run. - :vartype configured_duration: str - :ivar os_type: Operating system target of the software update configuration triggered this run. - :vartype os_type: str - :ivar start_time: Start time of the software update configuration run. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the software update configuration run. - :vartype end_time: ~datetime.datetime - :ivar computer_count: Number of computers in the software update configuration run. - :vartype computer_count: int - :ivar failed_count: Number of computers with failed status. - :vartype failed_count: int - :ivar creation_time: Creation time of the resource, which only appears in the response. - :vartype creation_time: ~datetime.datetime - :ivar created_by: CreatedBy property, which only appears in the response. - :vartype created_by: str - :ivar last_modified_time: Last time resource was modified, which only appears in the response. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: LastModifiedBy property, which only appears in the response. - :vartype last_modified_by: str - :param tasks: Software update configuration tasks triggered in this run. - :type tasks: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTasks - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'status': {'readonly': True}, - 'configured_duration': {'readonly': True}, - 'os_type': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'computer_count': {'readonly': True}, - 'failed_count': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'software_update_configuration': {'key': 'properties.softwareUpdateConfiguration', 'type': 'UpdateConfigurationNavigation'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'configured_duration': {'key': 'properties.configuredDuration', 'type': 'str'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'computer_count': {'key': 'properties.computerCount', 'type': 'int'}, - 'failed_count': {'key': 'properties.failedCount', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'tasks': {'key': 'properties.tasks', 'type': 'SoftwareUpdateConfigurationRunTasks'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRun, self).__init__(**kwargs) - self.name = None - self.id = None - self.software_update_configuration = kwargs.get('software_update_configuration', None) - self.status = None - self.configured_duration = None - self.os_type = None - self.start_time = None - self.end_time = None - self.computer_count = None - self.failed_count = None - self.creation_time = None - self.created_by = None - self.last_modified_time = None - self.last_modified_by = None - self.tasks = kwargs.get('tasks', None) - - -class SoftwareUpdateConfigurationRunListResult(msrest.serialization.Model): - """result of listing all software update configuration runs. - - :param value: outer object returned when listing all software update configuration runs. - :type value: list[~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun] - :param next_link: link to next page of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SoftwareUpdateConfigurationRun]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SoftwareUpdateConfigurationRunTaskProperties(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param status: The status of the task. - :type status: str - :param source: The name of the source of the task. - :type source: str - :param job_id: The job id of the task. - :type job_id: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - 'job_id': {'key': 'jobId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunTaskProperties, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.source = kwargs.get('source', None) - self.job_id = kwargs.get('job_id', None) - - -class SoftwareUpdateConfigurationRunTasks(msrest.serialization.Model): - """Software update configuration run tasks model. - - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunTaskProperties - """ - - _attribute_map = { - 'pre_task': {'key': 'preTask', 'type': 'SoftwareUpdateConfigurationRunTaskProperties'}, - 'post_task': {'key': 'postTask', 'type': 'SoftwareUpdateConfigurationRunTaskProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationRunTasks, self).__init__(**kwargs) - self.pre_task = kwargs.get('pre_task', None) - self.post_task = kwargs.get('post_task', None) - - -class SoftwareUpdateConfigurationTasks(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param pre_task: Pre task properties. - :type pre_task: ~azure.mgmt.automation.models.TaskProperties - :param post_task: Post task properties. - :type post_task: ~azure.mgmt.automation.models.TaskProperties - """ - - _attribute_map = { - 'pre_task': {'key': 'preTask', 'type': 'TaskProperties'}, - 'post_task': {'key': 'postTask', 'type': 'TaskProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SoftwareUpdateConfigurationTasks, self).__init__(**kwargs) - self.pre_task = kwargs.get('pre_task', None) - self.post_task = kwargs.get('post_task', None) - - -class SourceControl(Resource): - """Definition of the source control. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for - VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub. Possible values - include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param description: The description. - :type description: str - :param creation_time: The creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: The last modified time. - :type last_modified_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'repo_url': {'key': 'properties.repoUrl', 'type': 'str'}, - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControl, self).__init__(**kwargs) - self.repo_url = kwargs.get('repo_url', None) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.source_type = kwargs.get('source_type', None) - self.description = kwargs.get('description', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - - -class SourceControlCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update source control operation. - - :param repo_url: The repo url of the source control. - :type repo_url: str - :param branch: The repo branch of the source control. Include branch as empty string for - VsoTfvc. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto async of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param source_type: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive. - Possible values include: "VsoGit", "VsoTfvc", "GitHub". - :type source_type: str or ~azure.mgmt.automation.models.SourceType - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str - """ - - _validation = { - 'repo_url': {'max_length': 2000, 'min_length': 0}, - 'branch': {'max_length': 255, 'min_length': 0}, - 'folder_path': {'max_length': 255, 'min_length': 0}, - 'description': {'max_length': 512, 'min_length': 0}, - } - - _attribute_map = { - 'repo_url': {'key': 'properties.repoUrl', 'type': 'str'}, - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'SourceControlSecurityTokenProperties'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlCreateOrUpdateParameters, self).__init__(**kwargs) - self.repo_url = kwargs.get('repo_url', None) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.source_type = kwargs.get('source_type', None) - self.security_token = kwargs.get('security_token', None) - self.description = kwargs.get('description', None) - - -class SourceControlListResult(msrest.serialization.Model): - """The response model for the list source controls operation. - - :param value: The list of source controls. - :type value: list[~azure.mgmt.automation.models.SourceControl] - :param next_link: The next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControl]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SourceControlSecurityTokenProperties(msrest.serialization.Model): - """SourceControlSecurityTokenProperties. - - :param access_token: The access token. - :type access_token: str - :param refresh_token: The refresh token. - :type refresh_token: str - :param token_type: The token type. Must be either PersonalAccessToken or Oauth. Possible values - include: "PersonalAccessToken", "Oauth". - :type token_type: str or ~azure.mgmt.automation.models.TokenType - """ - - _validation = { - 'access_token': {'max_length': 1024, 'min_length': 0}, - 'refresh_token': {'max_length': 1024, 'min_length': 0}, - } - - _attribute_map = { - 'access_token': {'key': 'accessToken', 'type': 'str'}, - 'refresh_token': {'key': 'refreshToken', 'type': 'str'}, - 'token_type': {'key': 'tokenType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSecurityTokenProperties, self).__init__(**kwargs) - self.access_token = kwargs.get('access_token', None) - self.refresh_token = kwargs.get('refresh_token', None) - self.token_type = kwargs.get('token_type', None) - - -class SourceControlSyncJob(msrest.serialization.Model): - """Definition of the source control sync job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_id': {'key': 'properties.sourceControlSyncJobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'sync_type': {'key': 'properties.syncType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJob, self).__init__(**kwargs) - self.name = None - self.type = None - self.id = None - self.source_control_sync_job_id = kwargs.get('source_control_sync_job_id', None) - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.start_time = None - self.end_time = None - self.sync_type = kwargs.get('sync_type', None) - - -class SourceControlSyncJobById(msrest.serialization.Model): - """Definition of the source control sync job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: The id of the job. - :type id: str - :param source_control_sync_job_id: The source control sync job id. - :type source_control_sync_job_id: str - :ivar creation_time: The creation time of the job. - :vartype creation_time: ~datetime.datetime - :param provisioning_state: The provisioning state of the job. Possible values include: - "Completed", "Failed", "Running". - :type provisioning_state: str or ~azure.mgmt.automation.models.ProvisioningState - :ivar start_time: The start time of the job. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the job. - :vartype end_time: ~datetime.datetime - :param sync_type: The sync type. Possible values include: "PartialSync", "FullSync". - :type sync_type: str or ~azure.mgmt.automation.models.SyncType - :param exception: The exceptions that occurred while running the sync job. - :type exception: str - """ - - _validation = { - 'creation_time': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_id': {'key': 'properties.sourceControlSyncJobId', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'sync_type': {'key': 'properties.syncType', 'type': 'str'}, - 'exception': {'key': 'properties.exception', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobById, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.source_control_sync_job_id = kwargs.get('source_control_sync_job_id', None) - self.creation_time = None - self.provisioning_state = kwargs.get('provisioning_state', None) - self.start_time = None - self.end_time = None - self.sync_type = kwargs.get('sync_type', None) - self.exception = kwargs.get('exception', None) - - -class SourceControlSyncJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create source control sync job operation. - - All required parameters must be populated in order to send to Azure. - - :param commit_id: Required. The commit id of the source control sync job. If not syncing to a - commitId, enter an empty string. - :type commit_id: str - """ - - _validation = { - 'commit_id': {'required': True}, - } - - _attribute_map = { - 'commit_id': {'key': 'properties.commitId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobCreateParameters, self).__init__(**kwargs) - self.commit_id = kwargs['commit_id'] - - -class SourceControlSyncJobListResult(msrest.serialization.Model): - """The response model for the list source control sync jobs operation. - - :param value: The list of source control sync jobs. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJob] - :param next_link: The next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlSyncJob]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SourceControlSyncJobStream(msrest.serialization.Model): - """Definition of the source control sync job stream. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str - :ivar time: The time of the sync job stream. - :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType - """ - - _validation = { - 'id': {'readonly': True}, - 'time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_stream_id': {'key': 'properties.sourceControlSyncJobStreamId', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStream, self).__init__(**kwargs) - self.id = None - self.source_control_sync_job_stream_id = kwargs.get('source_control_sync_job_stream_id', None) - self.summary = kwargs.get('summary', None) - self.time = None - self.stream_type = kwargs.get('stream_type', None) - - -class SourceControlSyncJobStreamById(msrest.serialization.Model): - """Definition of the source control sync job stream by id. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource id. - :vartype id: str - :param source_control_sync_job_stream_id: The sync job stream id. - :type source_control_sync_job_stream_id: str - :param summary: The summary of the sync job stream. - :type summary: str - :ivar time: The time of the sync job stream. - :vartype time: ~datetime.datetime - :param stream_type: The type of the sync job stream. Possible values include: "Error", - "Output". - :type stream_type: str or ~azure.mgmt.automation.models.StreamType - :param stream_text: The text of the sync job stream. - :type stream_text: str - :param value: The values of the job stream. - :type value: dict[str, object] - """ - - _validation = { - 'id': {'readonly': True}, - 'time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'source_control_sync_job_stream_id': {'key': 'properties.sourceControlSyncJobStreamId', 'type': 'str'}, - 'summary': {'key': 'properties.summary', 'type': 'str'}, - 'time': {'key': 'properties.time', 'type': 'iso-8601'}, - 'stream_type': {'key': 'properties.streamType', 'type': 'str'}, - 'stream_text': {'key': 'properties.streamText', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStreamById, self).__init__(**kwargs) - self.id = None - self.source_control_sync_job_stream_id = kwargs.get('source_control_sync_job_stream_id', None) - self.summary = kwargs.get('summary', None) - self.time = None - self.stream_type = kwargs.get('stream_type', None) - self.stream_text = kwargs.get('stream_text', None) - self.value = kwargs.get('value', None) - - -class SourceControlSyncJobStreamsListBySyncJob(msrest.serialization.Model): - """The response model for the list source control sync job streams operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of source control sync job streams. - :type value: list[~azure.mgmt.automation.models.SourceControlSyncJobStream] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControlSyncJobStream]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlSyncJobStreamsListBySyncJob, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SourceControlUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update source control operation. - - :param branch: The repo branch of the source control. - :type branch: str - :param folder_path: The folder path of the source control. Path must be relative. - :type folder_path: str - :param auto_sync: The auto sync of the source control. Default is false. - :type auto_sync: bool - :param publish_runbook: The auto publish of the source control. Default is true. - :type publish_runbook: bool - :param security_token: The authorization token for the repo of the source control. - :type security_token: ~azure.mgmt.automation.models.SourceControlSecurityTokenProperties - :param description: The user description of the source control. - :type description: str - """ - - _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'auto_sync': {'key': 'properties.autoSync', 'type': 'bool'}, - 'publish_runbook': {'key': 'properties.publishRunbook', 'type': 'bool'}, - 'security_token': {'key': 'properties.securityToken', 'type': 'SourceControlSecurityTokenProperties'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SourceControlUpdateParameters, self).__init__(**kwargs) - self.branch = kwargs.get('branch', None) - self.folder_path = kwargs.get('folder_path', None) - self.auto_sync = kwargs.get('auto_sync', None) - self.publish_runbook = kwargs.get('publish_runbook', None) - self.security_token = kwargs.get('security_token', None) - self.description = kwargs.get('description', None) - - -class Statistics(msrest.serialization.Model): - """Definition of the statistic. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar counter_property: Gets the property value of the statistic. - :vartype counter_property: str - :ivar counter_value: Gets the value of the statistic. - :vartype counter_value: long - :ivar start_time: Gets the startTime of the statistic. - :vartype start_time: ~datetime.datetime - :ivar end_time: Gets the endTime of the statistic. - :vartype end_time: ~datetime.datetime - :ivar id: Gets the id. - :vartype id: str - """ - - _validation = { - 'counter_property': {'readonly': True}, - 'counter_value': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'id': {'readonly': True}, - } - - _attribute_map = { - 'counter_property': {'key': 'counterProperty', 'type': 'str'}, - 'counter_value': {'key': 'counterValue', 'type': 'long'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Statistics, self).__init__(**kwargs) - self.counter_property = None - self.counter_value = None - self.start_time = None - self.end_time = None - self.id = None - - -class StatisticsListResult(msrest.serialization.Model): - """The response model for the list statistics operation. - - :param value: Gets or sets a list of statistics. - :type value: list[~azure.mgmt.automation.models.Statistics] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Statistics]'}, - } - - def __init__( - self, - **kwargs - ): - super(StatisticsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SUCScheduleProperties(msrest.serialization.Model): - """Definition of schedule parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param start_time: Gets or sets the start time of the schedule. - :type start_time: ~datetime.datetime - :ivar start_time_offset_minutes: Gets the start time's offset in minutes. - :vartype start_time_offset_minutes: float - :param expiry_time: Gets or sets the end time of the schedule. - :type expiry_time: ~datetime.datetime - :param expiry_time_offset_minutes: Gets or sets the expiry time's offset in minutes. - :type expiry_time_offset_minutes: float - :param is_enabled: Gets or sets a value indicating whether this schedule is enabled. - :type is_enabled: bool - :param next_run: Gets or sets the next run time of the schedule. - :type next_run: ~datetime.datetime - :param next_run_offset_minutes: Gets or sets the next run time's offset in minutes. - :type next_run_offset_minutes: float - :param interval: Gets or sets the interval of the schedule. - :type interval: long - :param frequency: Gets or sets the frequency of the schedule. Possible values include: - "OneTime", "Day", "Hour", "Week", "Month", "Minute". - :type frequency: str or ~azure.mgmt.automation.models.ScheduleFrequency - :param time_zone: Gets or sets the time zone of the schedule. - :type time_zone: str - :param advanced_schedule: Gets or sets the advanced schedule. - :type advanced_schedule: ~azure.mgmt.automation.models.AdvancedSchedule - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'start_time_offset_minutes': {'readonly': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'start_time_offset_minutes': {'key': 'startTimeOffsetMinutes', 'type': 'float'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'expiry_time_offset_minutes': {'key': 'expiryTimeOffsetMinutes', 'type': 'float'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'next_run': {'key': 'nextRun', 'type': 'iso-8601'}, - 'next_run_offset_minutes': {'key': 'nextRunOffsetMinutes', 'type': 'float'}, - 'interval': {'key': 'interval', 'type': 'long'}, - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'advanced_schedule': {'key': 'advancedSchedule', 'type': 'AdvancedSchedule'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SUCScheduleProperties, self).__init__(**kwargs) - self.start_time = kwargs.get('start_time', None) - self.start_time_offset_minutes = None - self.expiry_time = kwargs.get('expiry_time', None) - self.expiry_time_offset_minutes = kwargs.get('expiry_time_offset_minutes', None) - self.is_enabled = kwargs.get('is_enabled', False) - self.next_run = kwargs.get('next_run', None) - self.next_run_offset_minutes = kwargs.get('next_run_offset_minutes', None) - self.interval = kwargs.get('interval', None) - self.frequency = kwargs.get('frequency', None) - self.time_zone = kwargs.get('time_zone', None) - self.advanced_schedule = kwargs.get('advanced_schedule', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class TagSettingsProperties(msrest.serialization.Model): - """Tag filter information for the VM. - - :param tags: A set of tags. Dictionary of tags with its list of values. - :type tags: dict[str, list[str]] - :param filter_operator: Filter VMs by Any or All specified tags. Possible values include: - "All", "Any". - :type filter_operator: str or ~azure.mgmt.automation.models.TagOperators - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{[str]}'}, - 'filter_operator': {'key': 'filterOperator', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagSettingsProperties, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.filter_operator = kwargs.get('filter_operator', None) - - -class TargetProperties(msrest.serialization.Model): - """Group specific to the update configuration. - - :param azure_queries: List of Azure queries in the software update configuration. - :type azure_queries: list[~azure.mgmt.automation.models.AzureQueryProperties] - :param non_azure_queries: List of non Azure queries in the software update configuration. - :type non_azure_queries: list[~azure.mgmt.automation.models.NonAzureQueryProperties] - """ - - _attribute_map = { - 'azure_queries': {'key': 'azureQueries', 'type': '[AzureQueryProperties]'}, - 'non_azure_queries': {'key': 'nonAzureQueries', 'type': '[NonAzureQueryProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetProperties, self).__init__(**kwargs) - self.azure_queries = kwargs.get('azure_queries', None) - self.non_azure_queries = kwargs.get('non_azure_queries', None) - - -class TaskProperties(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param parameters: Gets or sets the parameters of the task. - :type parameters: dict[str, str] - :param source: Gets or sets the name of the runbook. - :type source: str - """ - - _attribute_map = { - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'source': {'key': 'source', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TaskProperties, self).__init__(**kwargs) - self.parameters = kwargs.get('parameters', None) - self.source = kwargs.get('source', None) - - -class TestJob(msrest.serialization.Model): - """Definition of the test job. - - :param creation_time: Gets or sets the creation time of the test job. - :type creation_time: ~datetime.datetime - :param status: Gets or sets the status of the test job. - :type status: str - :param status_details: Gets or sets the status details of the test job. - :type status_details: str - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - :param start_time: Gets or sets the start time of the test job. - :type start_time: ~datetime.datetime - :param end_time: Gets or sets the end time of the test job. - :type end_time: ~datetime.datetime - :param exception: Gets or sets the exception of the test job. - :type exception: str - :param last_modified_time: Gets or sets the last modified time of the test job. - :type last_modified_time: ~datetime.datetime - :param last_status_modified_time: Gets or sets the last status modified time of the test job. - :type last_status_modified_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param log_activity_trace: The activity-level tracing options of the runbook. - :type log_activity_trace: int - """ - - _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'status_details': {'key': 'statusDetails', 'type': 'str'}, - 'run_on': {'key': 'runOn', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'exception': {'key': 'exception', 'type': 'str'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, - 'last_status_modified_time': {'key': 'lastStatusModifiedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'log_activity_trace': {'key': 'logActivityTrace', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(TestJob, self).__init__(**kwargs) - self.creation_time = kwargs.get('creation_time', None) - self.status = kwargs.get('status', None) - self.status_details = kwargs.get('status_details', None) - self.run_on = kwargs.get('run_on', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.exception = kwargs.get('exception', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_status_modified_time = kwargs.get('last_status_modified_time', None) - self.parameters = kwargs.get('parameters', None) - self.log_activity_trace = kwargs.get('log_activity_trace', None) - - -class TestJobCreateParameters(msrest.serialization.Model): - """The parameters supplied to the create test job operation. - - :param parameters: Gets or sets the parameters of the test job. - :type parameters: dict[str, str] - :param run_on: Gets or sets the runOn which specifies the group name where the job is to be - executed. - :type run_on: str - """ - - _attribute_map = { - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'run_on': {'key': 'runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TestJobCreateParameters, self).__init__(**kwargs) - self.parameters = kwargs.get('parameters', None) - self.run_on = kwargs.get('run_on', None) - - -class TypeField(msrest.serialization.Model): - """Information about a field of a type. - - :param name: Gets or sets the name of the field. - :type name: str - :param type: Gets or sets the type of the field. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TypeField, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class TypeFieldListResult(msrest.serialization.Model): - """The response model for the list fields operation. - - :param value: Gets or sets a list of fields. - :type value: list[~azure.mgmt.automation.models.TypeField] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TypeField]'}, - } - - def __init__( - self, - **kwargs - ): - super(TypeFieldListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UpdateConfiguration(msrest.serialization.Model): - """Update specific properties of the software update configuration. - - All required parameters must be populated in order to send to Azure. - - :param operating_system: Required. operating system of target machines. Possible values - include: "Windows", "Linux". - :type operating_system: str or ~azure.mgmt.automation.models.OperatingSystemType - :param windows: Windows specific update configuration. - :type windows: ~azure.mgmt.automation.models.WindowsProperties - :param linux: Linux specific update configuration. - :type linux: ~azure.mgmt.automation.models.LinuxProperties - :param duration: Maximum time allowed for the software update configuration run. Duration needs - to be specified using the format PT[n]H[n]M[n]S as per ISO8601. - :type duration: ~datetime.timedelta - :param azure_virtual_machines: List of azure resource Ids for azure virtual machines targeted - by the software update configuration. - :type azure_virtual_machines: list[str] - :param non_azure_computer_names: List of names of non-azure machines targeted by the software - update configuration. - :type non_azure_computer_names: list[str] - :param targets: Group targets for the software update configuration. - :type targets: ~azure.mgmt.automation.models.TargetProperties - """ - - _validation = { - 'operating_system': {'required': True}, - } - - _attribute_map = { - 'operating_system': {'key': 'operatingSystem', 'type': 'str'}, - 'windows': {'key': 'windows', 'type': 'WindowsProperties'}, - 'linux': {'key': 'linux', 'type': 'LinuxProperties'}, - 'duration': {'key': 'duration', 'type': 'duration'}, - 'azure_virtual_machines': {'key': 'azureVirtualMachines', 'type': '[str]'}, - 'non_azure_computer_names': {'key': 'nonAzureComputerNames', 'type': '[str]'}, - 'targets': {'key': 'targets', 'type': 'TargetProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateConfiguration, self).__init__(**kwargs) - self.operating_system = kwargs['operating_system'] - self.windows = kwargs.get('windows', None) - self.linux = kwargs.get('linux', None) - self.duration = kwargs.get('duration', None) - self.azure_virtual_machines = kwargs.get('azure_virtual_machines', None) - self.non_azure_computer_names = kwargs.get('non_azure_computer_names', None) - self.targets = kwargs.get('targets', None) - - -class UpdateConfigurationNavigation(msrest.serialization.Model): - """Software update configuration Run Navigation model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the software update configuration triggered the software update - configuration run. - :vartype name: str - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateConfigurationNavigation, self).__init__(**kwargs) - self.name = None - - -class Usage(msrest.serialization.Model): - """Definition of Usage. - - :param id: Gets or sets the id of the resource. - :type id: str - :param name: Gets or sets the usage counter name. - :type name: ~azure.mgmt.automation.models.UsageCounterName - :param unit: Gets or sets the usage unit name. - :type unit: str - :param current_value: Gets or sets the current usage value. - :type current_value: float - :param limit: Gets or sets max limit. -1 for unlimited. - :type limit: long - :param throttle_status: Gets or sets the throttle status. - :type throttle_status: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'UsageCounterName'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'throttle_status': {'key': 'throttleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Usage, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.throttle_status = kwargs.get('throttle_status', None) - - -class UsageCounterName(msrest.serialization.Model): - """Definition of usage counter name. - - :param value: Gets or sets the usage counter name. - :type value: str - :param localized_value: Gets or sets the localized usage counter name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageCounterName, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class UsageListResult(msrest.serialization.Model): - """The response model for the get usage operation. - - :param value: Gets or sets usage. - :type value: list[~azure.mgmt.automation.models.Usage] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, - } - - def __init__( - self, - **kwargs - ): - super(UsageListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Variable(Resource): - """Definition of the variable. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param value: Gets or sets the value of the variable. - :type value: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'is_encrypted': {'key': 'properties.isEncrypted', 'type': 'bool'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Variable, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.is_encrypted = kwargs.get('is_encrypted', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.description = kwargs.get('description', None) - - -class VariableCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update variable operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str - :param is_encrypted: Gets or sets the encrypted flag of the variable. - :type is_encrypted: bool - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_encrypted': {'key': 'properties.isEncrypted', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.value = kwargs.get('value', None) - self.description = kwargs.get('description', None) - self.is_encrypted = kwargs.get('is_encrypted', None) - - -class VariableListResult(msrest.serialization.Model): - """The response model for the list variables operation. - - :param value: Gets or sets a list of variables. - :type value: list[~azure.mgmt.automation.models.Variable] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Variable]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class VariableUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update variable operation. - - :param name: Gets or sets the name of the variable. - :type name: str - :param value: Gets or sets the value of the variable. - :type value: str - :param description: Gets or sets the description of the variable. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VariableUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - self.description = kwargs.get('description', None) - - -class Watcher(Resource): - """Definition of the watcher type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The geo-location where the resource lives. - :type location: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is - invoked. - :type execution_frequency_in_seconds: long - :param script_name: Gets or sets the name of the script the watcher is attached to, i.e. the - name of an existing runbook. - :type script_name: str - :param script_parameters: Gets or sets the parameters of the script. - :type script_parameters: dict[str, str] - :param script_run_on: Gets or sets the name of the hybrid worker group the watcher will run on. - :type script_run_on: str - :ivar status: Gets the current status of the watcher. - :vartype status: str - :ivar creation_time: Gets or sets the creation time. - :vartype creation_time: ~datetime.datetime - :ivar last_modified_time: Gets or sets the last modified time. - :vartype last_modified_time: ~datetime.datetime - :ivar last_modified_by: Details of the user who last modified the watcher. - :vartype last_modified_by: str - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'execution_frequency_in_seconds': {'key': 'properties.executionFrequencyInSeconds', 'type': 'long'}, - 'script_name': {'key': 'properties.scriptName', 'type': 'str'}, - 'script_parameters': {'key': 'properties.scriptParameters', 'type': '{str}'}, - 'script_run_on': {'key': 'properties.scriptRunOn', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Watcher, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - self.execution_frequency_in_seconds = kwargs.get('execution_frequency_in_seconds', None) - self.script_name = kwargs.get('script_name', None) - self.script_parameters = kwargs.get('script_parameters', None) - self.script_run_on = kwargs.get('script_run_on', None) - self.status = None - self.creation_time = None - self.last_modified_time = None - self.last_modified_by = None - self.description = kwargs.get('description', None) - - -class WatcherListResult(msrest.serialization.Model): - """The response model for the list watcher operation. - - :param value: Gets or sets a list of watchers. - :type value: list[~azure.mgmt.automation.models.Watcher] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Watcher]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WatcherListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class WatcherUpdateParameters(msrest.serialization.Model): - """WatcherUpdateParameters. - - :param name: Gets or sets the name of the resource. - :type name: str - :param execution_frequency_in_seconds: Gets or sets the frequency at which the watcher is - invoked. - :type execution_frequency_in_seconds: long - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'execution_frequency_in_seconds': {'key': 'properties.executionFrequencyInSeconds', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WatcherUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.execution_frequency_in_seconds = kwargs.get('execution_frequency_in_seconds', None) - - -class Webhook(Resource): - """Definition of the webhook type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param is_enabled: Gets or sets the value of the enabled flag of the webhook. - :type is_enabled: bool - :param uri: Gets or sets the webhook uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param last_invoked_time: Gets or sets the last invoked time. - :type last_invoked_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job that is created when the webhook - calls the runbook it is associated with. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook the webhook is associated with. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param creation_time: Gets or sets the creation time. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time. - :type last_modified_time: ~datetime.datetime - :param last_modified_by: Details of the user who last modified the Webhook. - :type last_modified_by: str - :param description: Gets or sets the description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'last_invoked_time': {'key': 'properties.lastInvokedTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Webhook, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', False) - self.uri = kwargs.get('uri', None) - self.expiry_time = kwargs.get('expiry_time', None) - self.last_invoked_time = kwargs.get('last_invoked_time', None) - self.parameters = kwargs.get('parameters', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - self.creation_time = kwargs.get('creation_time', None) - self.last_modified_time = kwargs.get('last_modified_time', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.description = kwargs.get('description', None) - - -class WebhookCreateOrUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the create or update webhook operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param uri: Gets or sets the uri. - :type uri: str - :param expiry_time: Gets or sets the expiry time. - :type expiry_time: ~datetime.datetime - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param runbook: Gets or sets the runbook. - :type runbook: ~azure.mgmt.automation.models.RunbookAssociationProperty - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'expiry_time': {'key': 'properties.expiryTime', 'type': 'iso-8601'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'runbook': {'key': 'properties.runbook', 'type': 'RunbookAssociationProperty'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - self.is_enabled = kwargs.get('is_enabled', None) - self.uri = kwargs.get('uri', None) - self.expiry_time = kwargs.get('expiry_time', None) - self.parameters = kwargs.get('parameters', None) - self.runbook = kwargs.get('runbook', None) - self.run_on = kwargs.get('run_on', None) - - -class WebhookListResult(msrest.serialization.Model): - """The response model for the list webhook operation. - - :param value: Gets or sets a list of webhooks. - :type value: list[~azure.mgmt.automation.models.Webhook] - :param next_link: Gets or sets the next link. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Webhook]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class WebhookUpdateParameters(msrest.serialization.Model): - """The parameters supplied to the update webhook operation. - - :param name: Gets or sets the name of the webhook. - :type name: str - :param is_enabled: Gets or sets the value of the enabled flag of webhook. - :type is_enabled: bool - :param run_on: Gets or sets the name of the hybrid worker group the webhook job will run on. - :type run_on: str - :param parameters: Gets or sets the parameters of the job. - :type parameters: dict[str, str] - :param description: Gets or sets the description of the webhook. - :type description: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'run_on': {'key': 'properties.runOn', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.run_on = kwargs.get('run_on', None) - self.parameters = kwargs.get('parameters', None) - self.description = kwargs.get('description', None) - - -class WindowsProperties(msrest.serialization.Model): - """Windows specific update configuration. - - :param included_update_classifications: Update classification included in the software update - configuration. A comma separated string with required values. Possible values include: - "Unclassified", "Critical", "Security", "UpdateRollup", "FeaturePack", "ServicePack", - "Definition", "Tools", "Updates". - :type included_update_classifications: str or - ~azure.mgmt.automation.models.WindowsUpdateClasses - :param excluded_kb_numbers: KB numbers excluded from the software update configuration. - :type excluded_kb_numbers: list[str] - :param included_kb_numbers: KB numbers included from the software update configuration. - :type included_kb_numbers: list[str] - :param reboot_setting: Reboot setting for the software update configuration. - :type reboot_setting: str - """ - - _attribute_map = { - 'included_update_classifications': {'key': 'includedUpdateClassifications', 'type': 'str'}, - 'excluded_kb_numbers': {'key': 'excludedKbNumbers', 'type': '[str]'}, - 'included_kb_numbers': {'key': 'includedKbNumbers', 'type': '[str]'}, - 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsProperties, self).__init__(**kwargs) - self.included_update_classifications = kwargs.get('included_update_classifications', None) - self.excluded_kb_numbers = kwargs.get('excluded_kb_numbers', None) - self.included_kb_numbers = kwargs.get('included_kb_numbers', None) - self.reboot_setting = kwargs.get('reboot_setting', None) diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/models/_models_py3.py index 7fbb522912f4..fd5074316e34 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,14 @@ class ProxyResource(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.automation.models.PrivateEndpointProperty + :ivar group_ids: Gets the groupIds. + :vartype group_ids: list[str] + :ivar private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.automation.models.PrivateLinkServiceConnectionStateProperty """ _validation = { @@ -3775,13 +5279,195 @@ class ProxyResource(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, + 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, + 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, } def __init__( self, + *, + private_endpoint: Optional["PrivateEndpointProperty"] = None, + group_ids: Optional[List[str]] = 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 group_ids: Gets the groupIds. + :paramtype group_ids: list[str] + :keyword private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.automation.models.PrivateLinkServiceConnectionStateProperty + """ + super(PrivateEndpointConnection, self).__init__(**kwargs) + self.private_endpoint = private_endpoint + self.group_ids = group_ids + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateEndpointConnectionListResult(msrest.serialization.Model): + """A list of private endpoint connections. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.automation.models.PrivateEndpointConnection] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + } + + def __init__( + self, + *, + value: Optional[List["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 +5475,10 @@ class PythonPackageCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param content_link: Required. Gets or sets the module content link. - :type content_link: ~azure.mgmt.automation.models.ContentLink + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] + :ivar content_link: Required. Gets or sets the module content link. + :vartype content_link: ~azure.mgmt.automation.models.ContentLink """ _validation = { @@ -3811,6 +5497,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 +5511,8 @@ def __init__( class PythonPackageUpdateParameters(msrest.serialization.Model): """The parameters supplied to the update module operation. - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the tags attached to the resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -3833,15 +5525,60 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets the tags attached to the resource. + :paramtype tags: dict[str, str] + """ super(PythonPackageUpdateParameters, self).__init__(**kwargs) self.tags = tags +class RawGraphicalRunbookContent(msrest.serialization.Model): + """Raw Graphical Runbook content. + + :ivar schema_version: Schema version of the serializer. + :vartype schema_version: str + :ivar runbook_definition: Serialized Graphical runbook. + :vartype runbook_definition: str + :ivar runbook_type: Runbook Type. 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 +5591,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the credential. + :paramtype name: str + """ super(RunAsCredentialAssociationProperty, self).__init__(**kwargs) self.name = name @@ -3869,52 +5610,52 @@ class Runbook(TrackedResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: The Azure Region where the resource lives. - :type location: str - :param etag: Gets or sets the etag of the resource. - :type etag: str - :param runbook_type: Gets or sets the type of the runbook. Possible values include: "Script", - "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell". - :type runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum - :param publish_content_link: Gets or sets the published runbook content link. - :type publish_content_link: ~azure.mgmt.automation.models.ContentLink - :param state: Gets or sets the state of the runbook. Possible values include: "New", "Edit", + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: The Azure Region where the resource lives. + :vartype location: str + :ivar etag: Gets or sets the etag of the resource. + :vartype etag: str + :ivar runbook_type: Gets or sets the type of the runbook. Possible values include: "Script", + "Graph", "PowerShellWorkflow", "PowerShell", "GraphPowerShellWorkflow", "GraphPowerShell", + "Python2", "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar publish_content_link: Gets or sets the published runbook content link. + :vartype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar state: Gets or sets the state of the runbook. 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 +5682,6 @@ class Runbook(TrackedResource): 'description': {'key': 'properties.description', 'type': 'str'}, } - provisioning_state = "Succeeded" - def __init__( self, *, @@ -3959,12 +5698,55 @@ 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", + "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword publish_content_link: Gets or sets the published runbook content link. + :paramtype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :keyword state: Gets or sets the state of the runbook. 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 +5759,7 @@ def __init__( self.parameters = parameters self.output_types = output_types self.draft = draft + self.provisioning_state = provisioning_state self.last_modified_by = last_modified_by self.creation_time = creation_time self.last_modified_time = last_modified_time @@ -3986,8 +5769,8 @@ def __init__( class RunbookAssociationProperty(msrest.serialization.Model): """The runbook property associated with the entity. - :param name: Gets or sets the name of the runbook. - :type name: str + :ivar name: Gets or sets the name of the runbook. + :vartype name: str """ _attribute_map = { @@ -4000,6 +5783,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the runbook. + :paramtype name: str + """ super(RunbookAssociationProperty, self).__init__(**kwargs) self.name = name @@ -4009,8 +5796,8 @@ class RunbookCreateOrUpdateDraftParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param runbook_content: Required. Content of the Runbook. - :type runbook_content: str + :ivar runbook_content: Required. Content of the Runbook. + :vartype runbook_content: str """ _validation = { @@ -4027,6 +5814,10 @@ def __init__( runbook_content: str, **kwargs ): + """ + :keyword runbook_content: Required. Content of the Runbook. + :paramtype runbook_content: str + """ super(RunbookCreateOrUpdateDraftParameters, self).__init__(**kwargs) self.runbook_content = runbook_content @@ -4036,20 +5827,20 @@ class RunbookCreateOrUpdateDraftProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: + :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 + "GraphPowerShell", "Python2", "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar draft: Required. Gets or sets the draft runbook properties. + :vartype draft: ~azure.mgmt.automation.models.RunbookDraft + :ivar description: Gets or sets the description of the runbook. + :vartype description: str + :ivar log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _validation = { @@ -4077,6 +5868,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", "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword draft: Required. Gets or sets the draft runbook properties. + :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft + :keyword description: Gets or sets the description of the runbook. + :paramtype description: str + :keyword log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(RunbookCreateOrUpdateDraftProperties, self).__init__(**kwargs) self.log_verbose = log_verbose self.log_progress = log_progress @@ -4091,28 +5898,28 @@ class RunbookCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Gets or sets the name of the resource. - :type name: str - :param location: Gets or sets the location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets the tags attached to the resource. - :type tags: dict[str, str] - :param log_verbose: Gets or sets verbose log option. - :type log_verbose: bool - :param log_progress: Gets or sets progress log option. - :type log_progress: bool - :param runbook_type: Required. Gets or sets the type of the runbook. Possible values include: + :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 + "GraphPowerShell", "Python2", "Python3". + :vartype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :ivar draft: Gets or sets the draft runbook properties. + :vartype draft: ~azure.mgmt.automation.models.RunbookDraft + :ivar publish_content_link: Gets or sets the published runbook content link. + :vartype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar description: Gets or sets the description of the runbook. + :vartype description: str + :ivar log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :vartype log_activity_trace: int """ _validation = { @@ -4147,6 +5954,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", "Python2", "Python3". + :paramtype runbook_type: str or ~azure.mgmt.automation.models.RunbookTypeEnum + :keyword draft: Gets or sets the draft runbook properties. + :paramtype draft: ~azure.mgmt.automation.models.RunbookDraft + :keyword publish_content_link: Gets or sets the published runbook content link. + :paramtype publish_content_link: ~azure.mgmt.automation.models.ContentLink + :keyword description: Gets or sets the description of the runbook. + :paramtype description: str + :keyword log_activity_trace: Gets or sets the activity-level tracing options of the runbook. + :paramtype log_activity_trace: int + """ super(RunbookCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -4163,18 +5994,18 @@ def __init__( class RunbookDraft(msrest.serialization.Model): """RunbookDraft. - :param in_edit: Gets or sets whether runbook is in edit mode. - :type in_edit: bool - :param draft_content_link: Gets or sets the draft runbook content link. - :type draft_content_link: ~azure.mgmt.automation.models.ContentLink - :param creation_time: Gets or sets the creation time of the runbook draft. - :type creation_time: ~datetime.datetime - :param last_modified_time: Gets or sets the last modified time of the runbook draft. - :type last_modified_time: ~datetime.datetime - :param parameters: Gets or sets the runbook draft parameters. - :type parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] - :param output_types: Gets or sets the runbook output types. - :type output_types: list[str] + :ivar in_edit: Gets or sets whether runbook is in edit mode. + :vartype in_edit: bool + :ivar draft_content_link: Gets or sets the draft runbook content link. + :vartype draft_content_link: ~azure.mgmt.automation.models.ContentLink + :ivar creation_time: Gets or sets the creation time of the runbook draft. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets or sets the last modified time of the runbook draft. + :vartype last_modified_time: ~datetime.datetime + :ivar parameters: Gets or sets the runbook draft parameters. + :vartype parameters: dict[str, ~azure.mgmt.automation.models.RunbookParameter] + :ivar output_types: Gets or sets the runbook output types. + :vartype output_types: list[str] """ _attribute_map = { @@ -4197,6 +6028,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 +6054,19 @@ def __init__( class RunbookDraftUndoEditResult(msrest.serialization.Model): """The response model for the undo edit runbook operation. - :param status_code: Possible values include: "Continue", "SwitchingProtocols", "OK", - "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", - "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", - "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", - "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", - "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", - "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", - "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", - "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", - "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", + :ivar status_code: 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 +6081,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 +6105,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 +6123,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 +6137,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 +6164,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 +6185,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 +6223,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 +6249,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 +6260,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 +6327,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 +6336,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 +6385,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 +6399,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 +6412,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 +6456,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 +6494,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 +6512,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 +6526,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 +6548,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 +6567,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 +6594,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 +6622,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 +6640,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 +6681,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 +6716,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 +6734,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 +6769,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 +6798,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 +6812,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 +6833,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 +6850,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 +6860,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 +6911,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 +6944,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 +6962,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 +6983,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 +7008,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 +7053,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 +7081,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 +7099,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 +7113,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 +7135,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 +7152,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 +7170,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 +7185,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 +7203,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 +7225,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 +7282,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 +7319,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 +7370,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 +7404,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 +7422,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 +7436,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 +7464,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 +7490,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 +7534,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 +7560,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 +7606,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 +7635,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 +7654,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 +7666,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 +7684,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 +7702,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 +7733,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 +7757,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 +7793,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 +7824,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 +7845,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 +7857,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 +7891,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 +7951,8 @@ def __init__( self, **kwargs ): + """ + """ super(Statistics, self).__init__(**kwargs) self.counter_property = None self.counter_value = None @@ -5789,8 +7964,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 +7978,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 +7991,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 +8061,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 +8107,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 +8193,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 +8208,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 +8226,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 +8240,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 +8258,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 +8272,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 +8327,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 +8369,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 +8388,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 +8403,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 +8421,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 +8435,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 +8449,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 +8462,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 +8508,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 +8560,8 @@ def __init__( self, **kwargs ): + """ + """ super(UpdateConfigurationNavigation, self).__init__(**kwargs) self.name = None @@ -6214,18 +8569,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 +8603,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 +8629,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 +8647,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 +8661,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 +8675,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 +8694,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 +8733,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 +8758,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 +8788,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 +8808,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 +8826,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 +8840,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 +8862,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 +8887,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 +8911,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 +8956,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 +8995,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 +9013,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 +9027,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 +9046,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 +9069,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 +9133,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 +9177,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 +9219,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 +9248,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 +9266,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 +9280,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 +9310,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 +9333,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 +9363,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 d7371312a9c8..23136da95dd4 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 b0fade70343f..0250a09fa62e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_activity_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_get_request( + resource_group_name: str, + automation_account_name: str, + module_name: str, + activity_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "activityName": _SERIALIZER.url("activity_name", activity_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _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 +125,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. @@ -64,6 +144,9 @@ def get( :type module_name: str :param activity_name: The name of activity. :type activity_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Activity, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Activity @@ -74,35 +157,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +191,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities/{activityName}"} # type: ignore + + + @distributed_trace def list_by_module( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActivityListResult"] + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> Iterable["_models.ActivityListResult"]: """Retrieve a list of activities in the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -129,47 +211,52 @@ def list_by_module( :type automation_account_name: str :param module_name: The name of module. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActivityListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ActivityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_module.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_module_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_module.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -178,17 +265,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_module.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities'} # type: ignore + list_by_module.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/activities"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py index 8424b6318383..a33207cc036e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_agent_registration_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,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 warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_get_request( + subscription_id: str, + resource_group_name: str, + automation_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _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,19 +127,22 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration @@ -67,33 +153,30 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +185,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation"} # type: ignore + + + @distributed_trace def regenerate_key( self, - resource_group_name, # type: str - automation_account_name, # type: str - parameters, # type: "_models.AgentRegistrationRegenerateKeyParameter" - **kwargs # type: Any - ): - # type: (...) -> "_models.AgentRegistration" + resource_group_name: str, + automation_account_name: str, + parameters: "_models.AgentRegistrationRegenerateKeyParameter", + **kwargs: Any + ) -> "_models.AgentRegistration": """Regenerate a primary or secondary agent registration key. :param resource_group_name: Name of an Azure Resource group. @@ -120,6 +205,9 @@ def regenerate_key( :type automation_account_name: str :param parameters: The name of the agent registration key to be regenerated. :type parameters: ~azure.mgmt.automation.models.AgentRegistrationRegenerateKeyParameter + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AgentRegistration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AgentRegistration @@ -130,38 +218,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AgentRegistrationRegenerateKeyParameter') + + request = build_regenerate_key_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +254,6 @@ def regenerate_key( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey'} # type: ignore + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/agentRegistrationInformation/regenerateKey"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py index e1f427427c47..8613d5e57dcd 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_account_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,251 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + 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 +274,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. @@ -61,6 +290,9 @@ def update( :type automation_account_name: str :param parameters: Parameters supplied to the update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -71,38 +303,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +339,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - parameters, # type: "_models.AutomationAccountCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutomationAccount" + resource_group_name: str, + automation_account_name: str, + parameters: "_models.AutomationAccountCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.AutomationAccount": """Create or update automation account. :param resource_group_name: Name of an Azure Resource group. @@ -129,6 +359,9 @@ def create_or_update( :type automation_account_name: str :param parameters: Parameters supplied to the create or update automation account. :type parameters: ~azure.mgmt.automation.models.AutomationAccountCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -139,38 +372,34 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutomationAccountCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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,21 +412,26 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> None: """Delete an automation account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -208,53 +442,54 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutomationAccount" + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> "_models.AutomationAccount": """Get information about an Automation Account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutomationAccount, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.AutomationAccount @@ -265,33 +500,30 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutomationAccount', pipeline_response) @@ -300,57 +532,63 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationAccountListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AutomationAccountListResult"]: """Retrieve a list of accounts within a given resource group. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -359,68 +597,76 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts"} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationAccountListResult"] + **kwargs: Any + ) -> Iterable["_models.AutomationAccountListResult"]: """Lists the Automation Accounts within an Azure subscription. Retrieve a list of accounts within a given subscription. + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationAccountListResult or the result of cls(response) + :return: An iterator like instance of either AutomationAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.AutomationAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationAccountListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -429,17 +675,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Automation/automationAccounts"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py new file mode 100644 index 000000000000..4713062bd815 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_automation_client_operations.py @@ -0,0 +1,141 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GraphicalRunbookContent, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.GraphicalRunbookContent + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GraphicalRunbookContent"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GraphicalRunbookContent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + convert_graph_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/convertGraphRunbookContent"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py index 9387b3b3e469..ec5480fc4d80 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + **kwargs: Any + ) -> None: """Delete the certificate. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +268,9 @@ def delete( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +281,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.Certificate": """Retrieve the certificate identified by certificate name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +330,9 @@ def get( :type automation_account_name: str :param certificate_name: The name of certificate. :type certificate_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -132,34 +343,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +376,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - parameters, # type: "_models.CertificateCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + parameters: "_models.CertificateCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Certificate": """Create a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +399,9 @@ def create_or_update( :type certificate_name: str :param parameters: The parameters supplied to the create or update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -199,39 +412,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +453,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - certificate_name, # type: str - parameters, # type: "_models.CertificateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Certificate" + resource_group_name: str, + automation_account_name: str, + certificate_name: str, + parameters: "_models.CertificateUpdateParameters", + **kwargs: Any + ) -> "_models.Certificate": """Update a certificate. :param resource_group_name: Name of an Azure Resource group. @@ -265,6 +476,9 @@ def update( :type certificate_name: str :param parameters: The parameters supplied to the update certificate operation. :type parameters: ~azure.mgmt.automation.models.CertificateUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Certificate @@ -275,39 +489,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CertificateUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Certificate', pipeline_response) @@ -316,61 +526,68 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates/{certificateName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CertificateListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.CertificateListResult"]: """Retrieve a list of certificates. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateListResult or the result of cls(response) + :return: An iterator like instance of either CertificateListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.CertificateListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,17 +596,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/certificates"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py index cb6d8fd83ae7..9d8eada20e79 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionName": _SERIALIZER.url("connection_name", connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + connection_name: str, + **kwargs: Any + ) -> None: """Delete the connection. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +268,9 @@ def delete( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +281,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + **kwargs: Any + ) -> "_models.Connection": """Retrieve the connection identified by connection name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +330,9 @@ def get( :type automation_account_name: str :param connection_name: The name of connection. :type connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -132,34 +343,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +376,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - parameters, # type: "_models.ConnectionCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + parameters: "_models.ConnectionCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Connection": """Create or update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +399,9 @@ def create_or_update( :type connection_name: str :param parameters: The parameters supplied to the create or update connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -199,39 +412,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +453,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_name, # type: str - parameters, # type: "_models.ConnectionUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Connection" + resource_group_name: str, + automation_account_name: str, + connection_name: str, + parameters: "_models.ConnectionUpdateParameters", + **kwargs: Any + ) -> "_models.Connection": """Update a connection. :param resource_group_name: Name of an Azure Resource group. @@ -265,6 +476,9 @@ def update( :type connection_name: str :param parameters: The parameters supplied to the update a connection operation. :type parameters: ~azure.mgmt.automation.models.ConnectionUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Connection, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Connection @@ -275,39 +489,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ConnectionUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Connection', pipeline_response) @@ -316,61 +526,68 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections/{connectionName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConnectionListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.ConnectionListResult"]: """Retrieve a list of connections. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionListResult or the result of cls(response) + :return: An iterator like instance of either ConnectionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,17 +596,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connections"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py index 51e8e25f5b37..19287775db6e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_connection_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "connectionTypeName": _SERIALIZER.url("connection_type_name", connection_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +206,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + **kwargs: Any + ) -> None: """Delete the connection type. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +222,9 @@ def delete( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +235,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectionType" + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + **kwargs: Any + ) -> "_models.ConnectionType": """Retrieve the connection type identified by connection type name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +284,9 @@ def get( :type automation_account_name: str :param connection_type_name: The name of connection type. :type connection_type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType @@ -132,34 +297,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +330,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - connection_type_name, # type: str - parameters, # type: "_models.ConnectionTypeCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectionType" + resource_group_name: str, + automation_account_name: str, + connection_type_name: str, + parameters: "_models.ConnectionTypeCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.ConnectionType": """Create a connection type. :param resource_group_name: Name of an Azure Resource group. @@ -190,6 +354,9 @@ def create_or_update( :type connection_type_name: str :param parameters: The parameters supplied to the create or update connection type operation. :type parameters: ~azure.mgmt.automation.models.ConnectionTypeCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConnectionType, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.ConnectionType @@ -200,39 +367,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConnectionTypeCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConnectionType', pipeline_response) @@ -241,61 +404,68 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes/{connectionTypeName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConnectionTypeListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.ConnectionTypeListResult"]: """Retrieve a list of connection types. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectionTypeListResult or the result of cls(response) + :return: An iterator like instance of either ConnectionTypeListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ConnectionTypeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionTypeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -304,17 +474,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/connectionTypes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py index 46682979714b..ef426f72052c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_credential_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "credentialName": _SERIALIZER.url("credential_name", credential_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + credential_name: str, + **kwargs: Any + ) -> None: """Delete the credential. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +268,9 @@ def delete( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +281,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + **kwargs: Any + ) -> "_models.Credential": """Retrieve the credential identified by credential name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +330,9 @@ def get( :type automation_account_name: str :param credential_name: The name of credential. :type credential_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -132,34 +343,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +376,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - parameters, # type: "_models.CredentialCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + parameters: "_models.CredentialCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Credential": """Create a credential. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +399,9 @@ def create_or_update( :type credential_name: str :param parameters: The parameters supplied to the create or update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -199,39 +412,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +453,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - credential_name, # type: str - parameters, # type: "_models.CredentialUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Credential" + resource_group_name: str, + automation_account_name: str, + credential_name: str, + parameters: "_models.CredentialUpdateParameters", + **kwargs: Any + ) -> "_models.Credential": """Update a credential. :param resource_group_name: Name of an Azure Resource group. @@ -265,6 +476,9 @@ def update( :type credential_name: str :param parameters: The parameters supplied to the Update credential operation. :type parameters: ~azure.mgmt.automation.models.CredentialUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Credential, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Credential @@ -275,39 +489,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CredentialUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CredentialUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Credential', pipeline_response) @@ -316,61 +526,68 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials/{credentialName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CredentialListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.CredentialListResult"]: """Retrieve a list of credentials. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CredentialListResult or the result of cls(response) + :return: An iterator like instance of either CredentialListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.CredentialListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.CredentialListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,7 +596,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,7 +609,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/credentials"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py index 753e49c664b7..2908a5351733 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,191 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 .. 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "compilationJobName": _SERIALIZER.url("compilation_job_name", compilation_job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "compilationJobName": _SERIALIZER.url("compilation_job_name", compilation_job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +216,46 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscCompilationJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [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 +263,19 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - automation_account_name, # type: str - compilation_job_name, # type: str - parameters, # type: "_models.DscCompilationJobCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DscCompilationJob"] + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + parameters: "_models.DscCompilationJobCreateParameters", + **kwargs: Any + ) -> LROPoller["_models.DscCompilationJob"]: """Creates the Dsc compilation job of the configuration. :param resource_group_name: Name of an Azure Resource group. @@ -123,16 +286,24 @@ def begin_create( :type compilation_job_name: str :param parameters: The parameters supplied to the create compilation job operation. :type parameters: ~azure.mgmt.automation.models.DscCompilationJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DscCompilationJob or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DscCompilationJob or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscCompilationJob] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJob"] lro_delay = kwargs.pop( @@ -146,28 +317,22 @@ def begin_create( automation_account_name=automation_account_name, compilation_job_name=compilation_job_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -177,18 +342,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - compilation_job_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscCompilationJob" + resource_group_name: str, + automation_account_name: str, + compilation_job_name: str, + **kwargs: Any + ) -> "_models.DscCompilationJob": """Retrieve the Dsc configuration compilation job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -197,6 +362,9 @@ def get( :type automation_account_name: str :param compilation_job_name: The DSC configuration Id. :type compilation_job_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscCompilationJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscCompilationJob @@ -207,34 +375,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscCompilationJob', pipeline_response) @@ -243,66 +408,73 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscCompilationJobListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DscCompilationJobListResult"]: """Retrieve a list of dsc compilation jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscCompilationJobListResult or the result of cls(response) + :return: An iterator like instance of either DscCompilationJobListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscCompilationJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscCompilationJobListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -311,30 +483,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs"} # type: ignore + @distributed_trace def get_stream( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_id, # type: str - job_stream_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobStream" + resource_group_name: str, + automation_account_name: str, + job_id: str, + job_stream_id: str, + **kwargs: Any + ) -> "_models.JobStream": """Retrieve the job stream identified by job stream id. :param resource_group_name: Name of an Azure Resource group. @@ -345,6 +522,9 @@ def get_stream( :type job_id: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -355,35 +535,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +569,6 @@ def get_stream( return cls(pipeline_response, deserialized, {}) return deserialized - get_stream.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}'} # type: ignore + + get_stream.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams/{jobStreamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py index 1726272bfbda..121110aaec44 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_compilation_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,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 warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +84,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. @@ -60,6 +100,9 @@ def list_by_job( :type automation_account_name: str :param job_id: The job id. :type job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStreamListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStreamListResult @@ -70,34 +113,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + template_url=self.list_by_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +146,6 @@ def list_by_job( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams'} # type: ignore + + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{jobId}/streams"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py index 48af11730a06..616e5147942f 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "text/powershell" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +303,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> None: """Delete the dsc configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +319,9 @@ def delete( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +332,47 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.DscConfiguration": """Retrieve the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +381,9 @@ def get( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -132,34 +394,31 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +427,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - parameters, # type: Union[str, "_models.DscConfigurationCreateOrUpdateParameters"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + parameters: Union[str, "_models.DscConfigurationCreateOrUpdateParameters"], + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -189,8 +452,12 @@ def create_or_update( :type configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationCreateOrUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain; charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -201,48 +468,45 @@ 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 + + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +519,21 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - parameters=None, # type: Optional[Union[str, "_models.DscConfigurationUpdateParameters"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.DscConfiguration" + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + parameters: Optional[Union[str, "_models.DscConfigurationUpdateParameters"]] = None, + *, + content_type: Optional[str] = "application/json", + **kwargs: Any + ) -> "_models.DscConfiguration": """Create the configuration identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -274,10 +542,14 @@ def update( :type automation_account_name: str :param configuration_name: The create or update parameters for configuration. :type configuration_name: str - :param parameters: The create or update parameters for configuration. + :param parameters: The create or update parameters for configuration. Default value is None. :type parameters: str or ~azure.mgmt.automation.models.DscConfigurationUpdateParameters - :keyword str content_type: Media type of the body sent to the API. Default value is "text/plain; charset=utf-8". - Allowed values are: "text/plain; charset=utf-8", "application/json". + :keyword content_type: Media type of the body sent to the API. Possible values are: + "text/plain; charset=utf-8" or "application/json". Default value is "application/json". + :paramtype content_type: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscConfiguration @@ -288,51 +560,45 @@ 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 + + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +607,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}"} # type: ignore + + + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + configuration_name: str, + **kwargs: Any + ) -> str: """Retrieve the configuration script identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -359,6 +627,9 @@ def get_content( :type automation_account_name: str :param configuration_name: The configuration name. :type configuration_name: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -369,29 +640,26 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_content_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_content.metadata['url'], + ) + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,81 +672,88 @@ def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscConfigurationListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DscConfigurationListResult"]: """Retrieve a list of configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscConfigurationListResult or the result of cls(response) + :return: An iterator like instance of either DscConfigurationListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -487,17 +762,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py index 45317cc8dfce..c80925ed0251 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 .. 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeConfigurationName": _SERIALIZER.url("node_configuration_name", node_configuration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +221,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any + ) -> None: """Delete the Dsc node configurations by node configuration. :param resource_group_name: Name of an Azure Resource group. @@ -63,6 +237,9 @@ def delete( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -73,49 +250,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNodeConfiguration" + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + **kwargs: Any + ) -> "_models.DscNodeConfiguration": """Retrieve the Dsc node configurations by node configuration. :param resource_group_name: Name of an Azure Resource group. @@ -124,6 +299,9 @@ def get( :type automation_account_name: str :param node_configuration_name: The Dsc node configuration name. :type node_configuration_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeConfiguration @@ -134,34 +312,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +345,52 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - parameters, # type: "_models.DscNodeConfigurationCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DscNodeConfiguration"] + 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DscNodeConfigurationCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_configuration_name=node_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +400,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_configuration_name, # type: str - parameters, # type: "_models.DscNodeConfigurationCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DscNodeConfiguration"] + resource_group_name: str, + automation_account_name: str, + node_configuration_name: str, + parameters: "_models.DscNodeConfigurationCreateOrUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.DscNodeConfiguration"]: """Create the node configuration identified by node configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -250,16 +423,24 @@ def begin_create_or_update( :type node_configuration_name: str :param parameters: The create or update parameters for configuration. :type parameters: ~azure.mgmt.automation.models.DscNodeConfigurationCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DscNodeConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.DscNodeConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfiguration"] lro_delay = kwargs.pop( @@ -273,28 +454,22 @@ def begin_create_or_update( automation_account_name=automation_account_name, node_configuration_name=node_configuration_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -304,83 +479,89 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations/{nodeConfigurationName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscNodeConfigurationListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DscNodeConfigurationListResult"]: """Retrieve a list of dsc node configurations. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeConfigurationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] + :return: An iterator like instance of either DscNodeConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeConfigurationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeConfigurationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -389,17 +570,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodeConfigurations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py index 49866da11b67..298a080f5e89 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_dsc_node_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +219,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + node_id: str, + **kwargs: Any + ) -> None: """Delete the dsc node identified by node id. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +235,9 @@ def delete( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +248,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNode" + resource_group_name: str, + automation_account_name: str, + node_id: str, + **kwargs: Any + ) -> "_models.DscNode": """Retrieve the dsc node identified by node id. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +297,9 @@ def get( :type automation_account_name: str :param node_id: The node id. :type node_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode @@ -132,34 +310,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +343,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - dsc_node_update_parameters, # type: "_models.DscNodeUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNode" + resource_group_name: str, + automation_account_name: str, + node_id: str, + dsc_node_update_parameters: "_models.DscNodeUpdateParameters", + **kwargs: Any + ) -> "_models.DscNode": """Update the dsc node. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +366,9 @@ def update( :type node_id: str :param dsc_node_update_parameters: Parameters supplied to the update dsc node. :type dsc_node_update_parameters: ~azure.mgmt.automation.models.DscNodeUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNode, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNode @@ -199,39 +379,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(dsc_node_update_parameters, 'DscNodeUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DscNode', pipeline_response) @@ -240,81 +416,87 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - inlinecount=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DscNodeListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + inlinecount: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DscNodeListResult"]: """Retrieve a list of dsc nodes. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param skip: The number of rows to skip. + :param skip: The number of rows to skip. Default value is None. :type skip: int - :param top: The number of rows to take. + :param top: The number of rows to take. Default value is None. :type top: int - :param inlinecount: Return total rows. + :param inlinecount: Return total rows. Default value is None. :type inlinecount: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DscNodeListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if inlinecount is not None: - query_parameters['$inlinecount'] = self._serialize.query("inlinecount", inlinecount, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + skip=skip, + top=top, + inlinecount=inlinecount, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -323,17 +505,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py index f1a689f580b7..8364fb225f12 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_fields_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +87,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. @@ -64,48 +106,54 @@ def list_by_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -114,17 +162,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields'} # type: ignore + list_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py index 63abed20de87..5d7f27347cb6 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_worker_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,233 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +256,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - hybrid_runbook_worker_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + **kwargs: Any + ) -> None: """Delete a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +272,9 @@ def delete( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +285,47 @@ 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - hybrid_runbook_worker_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridRunbookWorkerGroup" + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + **kwargs: Any + ) -> "_models.HybridRunbookWorkerGroup": """Retrieve a hybrid runbook worker group. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +334,9 @@ def get( :type automation_account_name: str :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup @@ -132,34 +347,106 @@ 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'), + + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorkerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - 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') + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + request = build_create_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +455,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 +477,11 @@ def update( :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. :type hybrid_runbook_worker_group_name: str :param parameters: The hybrid runbook worker group. - :type parameters: ~azure.mgmt.automation.models.HybridRunbookWorkerGroupUpdateParameters + :type parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerGroupCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridRunbookWorkerGroup, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.HybridRunbookWorkerGroup @@ -199,39 +492,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridRunbookWorkerGroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridRunbookWorkerGroup', pipeline_response) @@ -240,66 +529,74 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HybridRunbookWorkerGroupsListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.HybridRunbookWorkerGroupsListResult"]: """Retrieve a list of hybrid runbook worker groups. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] + :return: An iterator like instance of either HybridRunbookWorkerGroupsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkerGroupsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -308,17 +605,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py new file mode 100644 index 000000000000..e8c20753dca9 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_hybrid_runbook_workers_operations.py @@ -0,0 +1,653 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "hybridRunbookWorkerId": _SERIALIZER.url("hybrid_runbook_worker_id", hybrid_runbook_worker_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "hybridRunbookWorkerGroupName": _SERIALIZER.url("hybrid_runbook_worker_group_name", hybrid_runbook_worker_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> None: + """Delete a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2021-06-22") # type: 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, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + **kwargs: Any + ) -> "_models.HybridRunbookWorker": + """Retrieve a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + hybrid_runbook_worker_id=hybrid_runbook_worker_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def create( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_creation_parameters: "_models.HybridRunbookWorkerCreateParameters", + **kwargs: Any + ) -> "_models.HybridRunbookWorker": + """Create a hybrid runbook worker. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_creation_parameters: The create or update parameters for hybrid + runbook worker. + :type hybrid_runbook_worker_creation_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerCreateParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridRunbookWorker, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.HybridRunbookWorker + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorker"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridRunbookWorker', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}"} # type: ignore + + + @distributed_trace + def move( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + hybrid_runbook_worker_id: str, + hybrid_runbook_worker_move_parameters: "_models.HybridRunbookWorkerMoveParameters", + **kwargs: Any + ) -> None: + """Move a hybrid worker to a different group. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param hybrid_runbook_worker_id: The hybrid runbook worker id. + :type hybrid_runbook_worker_id: str + :param hybrid_runbook_worker_move_parameters: The hybrid runbook worker move parameters. + :type hybrid_runbook_worker_move_parameters: + ~azure.mgmt.automation.models.HybridRunbookWorkerMoveParameters + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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 = kwargs.pop('api_version', "2021-06-22") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + move.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers/{hybridRunbookWorkerId}/move"} # type: ignore + + + @distributed_trace + def list_by_hybrid_runbook_worker_group( + self, + resource_group_name: str, + automation_account_name: str, + hybrid_runbook_worker_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.HybridRunbookWorkersListResult"]: + """Retrieve a list of hybrid runbook workers. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param hybrid_runbook_worker_group_name: The hybrid runbook worker group name. + :type hybrid_runbook_worker_group_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridRunbookWorkersListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.HybridRunbookWorkersListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridRunbookWorkersListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_hybrid_runbook_worker_group_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + hybrid_runbook_worker_group_name=hybrid_runbook_worker_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_hybrid_runbook_worker_group.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_hybrid_runbook_worker_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/hybridRunbookWorkerGroups/{hybridRunbookWorkerGroupName}/hybridRunbookWorkers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py index 2afce74497f4..addf15a4daf1 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,369 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "text/plain" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "text/powershell" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +392,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. @@ -62,8 +409,11 @@ def get_output( :type automation_account_name: str :param job_name: The name of the job to be created. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -74,31 +424,27 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_output_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_output.metadata['url'], + ) + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,17 +457,19 @@ def get_output( return cls(pipeline_response, deserialized, {}) return deserialized - get_output.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output'} # type: ignore + get_output.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/output"} # type: ignore + + + @distributed_trace def get_runbook_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> str: """Retrieve the runbook content of the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -130,8 +478,11 @@ def get_runbook_content( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -142,31 +493,27 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_get_runbook_content_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.get_runbook_content.metadata['url'], + ) + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,17 +526,19 @@ def get_runbook_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_runbook_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent'} # type: ignore - def suspend( + get_runbook_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/runbookContent"} # type: ignore + + + @distributed_trace + def suspend( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Suspend the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -198,8 +547,11 @@ def suspend( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -210,52 +562,49 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_suspend_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.suspend.metadata['url'], + ) + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/suspend"} # type: ignore + - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Stop the job identified by jobName. :param resource_group_name: Name of an Azure Resource group. @@ -264,8 +613,11 @@ def stop( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -276,52 +628,49 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_stop_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + client_request_id=client_request_id, + template_url=self.stop.metadata['url'], + ) + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/stop"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.Job": """Retrieve the job identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -330,8 +679,11 @@ def get( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job @@ -342,36 +694,32 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +728,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - parameters, # type: "_models.JobCreateParameters" - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + resource_group_name: str, + automation_account_name: str, + job_name: str, + parameters: "_models.JobCreateParameters", + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.Job": """Create a job of the runbook. :param resource_group_name: Name of an Azure Resource group. @@ -402,8 +752,11 @@ def create( :type job_name: str :param parameters: The parameters supplied to the create job operation. :type parameters: ~azure.mgmt.automation.models.JobCreateParameters - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Job, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Job @@ -414,41 +767,36 @@ 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Job', pipeline_response) @@ -457,71 +805,77 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobListResultV2"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.JobListResultV2"]: """Retrieve a list of jobs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobListResultV2 or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobListResultV2] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobListResultV2"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -530,30 +884,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs"} # type: ignore - def resume( + @distributed_trace + def resume( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """Resume the job identified by jobName. :param resource_group_name: Name of an Azure Resource group. @@ -562,8 +921,11 @@ def resume( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -574,39 +936,36 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/resume"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py index d01e390ea63d..f22de95f8202 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,187 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobScheduleId": _SERIALIZER.url("job_schedule_id", job_schedule_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +210,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + **kwargs: Any + ) -> None: """Delete the job schedule identified by job schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +226,9 @@ def delete( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +239,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.JobSchedule" + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + **kwargs: Any + ) -> "_models.JobSchedule": """Retrieve the job schedule identified by job schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +288,9 @@ def get( :type automation_account_name: str :param job_schedule_id: The job schedule name. :type job_schedule_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule @@ -132,34 +301,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +334,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace def create( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_schedule_id, # type: str - parameters, # type: "_models.JobScheduleCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.JobSchedule" + resource_group_name: str, + automation_account_name: str, + job_schedule_id: str, + parameters: "_models.JobScheduleCreateParameters", + **kwargs: Any + ) -> "_models.JobSchedule": """Create a job schedule. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +357,9 @@ def create( :type job_schedule_id: str :param parameters: The parameters supplied to the create job schedule operation. :type parameters: ~azure.mgmt.automation.models.JobScheduleCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobSchedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobSchedule @@ -199,39 +370,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'JobScheduleCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobSchedule', pipeline_response) @@ -240,66 +407,73 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules/{jobScheduleId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobScheduleListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.JobScheduleListResult"]: """Retrieve a list of job schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobScheduleListResult or the result of cls(response) + :return: An iterator like instance of either JobScheduleListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -308,17 +482,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobSchedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py index 4db34971e8ba..3ae0ba0a478c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_job_stream_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "jobName": _SERIALIZER.url("job_name", job_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _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') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # 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 +136,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. @@ -65,8 +156,11 @@ def get( :type job_name: str :param job_stream_id: The job stream id. :type job_stream_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -77,37 +171,33 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +206,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - job_name, # type: str - filter=None, # type: Optional[str] - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStreamListResult"] + resource_group_name: str, + automation_account_name: str, + job_name: str, + filter: Optional[str] = None, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.JobStreamListResult"]: """Retrieve a list of jobs streams identified by job name. :param resource_group_name: Name of an Azure Resource group. @@ -136,55 +228,60 @@ def list_by_job( :type automation_account_name: str :param job_name: The job name. :type job_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if client_request_id is not None: - header_parameters['clientRequestId'] = self._serialize.header("client_request_id", client_request_id, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'jobName': self._serialize.url("job_name", job_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + client_request_id=client_request_id, + template_url=self.list_by_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -193,17 +290,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams'} # type: ignore + list_by_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs/{jobName}/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py index 247cd84ff235..db6509ba4c80 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,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 warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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,19 +82,22 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: KeyListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.KeyListResult @@ -67,33 +108,30 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-06-22") # type: 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, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +140,6 @@ def list_by_automation_account( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys'} # type: ignore + + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/listKeys"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py index ba38f637ec4f..5eab13823b72 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_linked_workspace_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,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 warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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,19 +82,22 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkedWorkspace, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.LinkedWorkspace @@ -67,33 +108,30 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +140,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/linkedWorkspace"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py index ccdfd980714a..72da7638d2f4 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_module_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> None: """Delete the module by name. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +268,9 @@ def delete( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +281,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + **kwargs: Any + ) -> "_models.Module": """Retrieve the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +330,9 @@ def get( :type automation_account_name: str :param module_name: The module name. :type module_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -132,34 +343,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +376,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - parameters, # type: "_models.ModuleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: "_models.ModuleCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Module": """Create or Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +399,9 @@ def create_or_update( :type module_name: str :param parameters: The create or update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -199,39 +412,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +453,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - module_name, # type: str - parameters, # type: "_models.ModuleUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + module_name: str, + parameters: "_models.ModuleUpdateParameters", + **kwargs: Any + ) -> "_models.Module": """Update the module identified by module name. :param resource_group_name: Name of an Azure Resource group. @@ -265,6 +476,9 @@ def update( :type module_name: str :param parameters: The update parameters for module. :type parameters: ~azure.mgmt.automation.models.ModuleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -275,39 +489,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ModuleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ModuleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -316,61 +526,67 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ModuleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.ModuleListResult"]: """Retrieve a list of modules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,17 +595,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py index d45cbc7268b9..6b25620531cb 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_count_information_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,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 warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "countType": _SERIALIZER.url("count_type", count_type, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +84,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. @@ -60,6 +100,9 @@ def get( :type automation_account_name: str :param count_type: The type of counts to retrieve. :type count_type: str or ~azure.mgmt.automation.models.CountType + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NodeCounts, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.NodeCounts @@ -70,34 +113,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +146,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodecounts/{countType}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py index 18ae4584c08a..a97a5792d0ce 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_node_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "nodeId": _SERIALIZER.url("node_id", node_id, 'str'), + "reportId": _SERIALIZER.url("report_id", report_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +169,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. @@ -62,51 +186,57 @@ def list_by_node( :type automation_account_name: str :param node_id: The parameters supplied to the list operation. :type node_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DscNodeReportListResult or the result of cls(response) + :return: An iterator like instance of either DscNodeReportListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.DscNodeReportListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DscNodeReportListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_node.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'nodeId': self._serialize.url("node_id", node_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_node_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + node_id=node_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_node.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -115,30 +245,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_node.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports'} # type: ignore + list_by_node.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - report_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DscNodeReport" + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + **kwargs: Any + ) -> "_models.DscNodeReport": """Retrieve the Dsc node report data by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -149,6 +284,9 @@ def get( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DscNodeReport, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.DscNodeReport @@ -159,35 +297,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +331,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}"} # type: ignore + + + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - node_id, # type: str - report_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> object + resource_group_name: str, + automation_account_name: str, + node_id: str, + report_id: str, + **kwargs: Any + ) -> Any: """Retrieve the Dsc node reports by node id and report id. :param resource_group_name: Name of an Azure Resource group. @@ -217,45 +354,45 @@ def get_content( :type node_id: str :param report_id: The report id. :type report_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] + 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +401,6 @@ def get_content( return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}/reports/{reportId}/content"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py index 4433d365aee4..7878145182df 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_object_data_types_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,102 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "moduleName": _SERIALIZER.url("module_name", module_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "typeName": _SERIALIZER.url("type_name", type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _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 +125,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. @@ -64,48 +144,54 @@ def list_fields_by_module_and_type( :type module_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_module_and_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'moduleName': self._serialize.url("module_name", module_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_module_and_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + module_name=module_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_module_and_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -114,29 +200,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_fields_by_module_and_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_module_and_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/objectDataTypes/{typeName}/fields"} # type: ignore + @distributed_trace def list_fields_by_type( self, - resource_group_name, # type: str - automation_account_name, # type: str - type_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TypeFieldListResult"] + resource_group_name: str, + automation_account_name: str, + type_name: str, + **kwargs: Any + ) -> Iterable["_models.TypeFieldListResult"]: """Retrieve a list of fields of a given type across all accessible modules. :param resource_group_name: Name of an Azure Resource group. @@ -145,47 +236,52 @@ def list_fields_by_type( :type automation_account_name: str :param type_name: The name of type. :type type_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TypeFieldListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.TypeFieldListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TypeFieldListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_fields_by_type.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'typeName': self._serialize.url("type_name", type_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_fields_by_type_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + type_name=type_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_fields_by_type.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -194,17 +290,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_fields_by_type.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields'} # type: ignore + list_fields_by_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/objectDataTypes/{typeName}/fields"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py index a26716803b06..3882ce497013 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2021-06-22") # type: str + + 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,47 +73,51 @@ 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 api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + 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( + api_version=api_version, + 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) @@ -94,17 +126,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Automation/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Automation/operations"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..534329d0ddcf --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,607 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": + """Gets a private endpoint connection. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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', {})) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param parameters: + :type parameters: ~azure.mgmt.automation.models.PrivateEndpointConnection + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.automation.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + api_version=api_version, + 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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + automation_account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. + :type private_endpoint_connection_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + **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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..34434a56dde2 --- /dev/null +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_private_link_resources_operations.py @@ -0,0 +1,170 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.PrivateLinkResourceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_automation_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.automation.metadata['url'], + ) + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + automation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/privateLinkResources"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py index f28cd6987093..1de03773b306 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_python2_package_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "packageName": _SERIALIZER.url("package_name", package_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def delete( + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + package_name: str, + **kwargs: Any + ) -> None: """Delete the python 2 package by name. :param resource_group_name: Name of an Azure Resource group. @@ -61,6 +268,9 @@ def delete( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -71,49 +281,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + **kwargs: Any + ) -> "_models.Module": """Retrieve the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -122,6 +330,9 @@ def get( :type automation_account_name: str :param package_name: The python package name. :type package_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -132,34 +343,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +376,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - parameters, # type: "_models.PythonPackageCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: "_models.PythonPackageCreateParameters", + **kwargs: Any + ) -> "_models.Module": """Create or Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -189,6 +399,9 @@ def create_or_update( :type package_name: str :param parameters: The create or update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -199,39 +412,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +453,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - package_name, # type: str - parameters, # type: "_models.PythonPackageUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Module" + resource_group_name: str, + automation_account_name: str, + package_name: str, + parameters: "_models.PythonPackageUpdateParameters", + **kwargs: Any + ) -> "_models.Module": """Update the python 2 package identified by package name. :param resource_group_name: Name of an Azure Resource group. @@ -265,6 +476,9 @@ def update( :type package_name: str :param parameters: The update parameters for python package. :type parameters: ~azure.mgmt.automation.models.PythonPackageUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Module, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Module @@ -275,39 +489,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PythonPackageUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PythonPackageUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + package_name=package_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Module', pipeline_response) @@ -316,61 +526,67 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ModuleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.ModuleListResult"]: """Retrieve a list of python 2 packages. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModuleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ModuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,17 +595,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py index c60a44fca278..ef25638b1f9c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_draft_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,24 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling 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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "text/powershell" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +207,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. @@ -62,120 +223,124 @@ def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + def _replace_content_initial( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - runbook_content, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + runbook_content: str, + **kwargs: Any + ) -> Optional[IO]: + 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(runbook_content, 'str') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] + + _content = runbook_content + + request = build_replace_content_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + content_type=content_type, + content=_content, + template_url=self._replace_content_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=True, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _replace_content_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore - _replace_content_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + @distributed_trace def begin_replace_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - runbook_content, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + runbook_content: str, + **kwargs: Any + ) -> LROPoller[IO]: """Replaces the runbook draft content. :param resource_group_name: Name of an Azure Resource group. @@ -184,20 +349,27 @@ def begin_replace_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param runbook_content: The runbook draft content. + :param runbook_content: The runbook draft content. :type runbook_content: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IO or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[IO] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "text/powershell") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType[IO] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -209,25 +381,22 @@ def begin_replace_content( automation_account_name=automation_account_name, runbook_name=runbook_name, runbook_content=runbook_content, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **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: @@ -237,18 +406,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_replace_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/content"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RunbookDraft" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> "_models.RunbookDraft": """Retrieve the runbook draft identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -257,6 +426,9 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RunbookDraft, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.RunbookDraft @@ -267,34 +439,31 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +472,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft"} # type: ignore + + + @distributed_trace def undo_edit( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> "_models.RunbookDraftUndoEditResult": """Undo draft edit to last known published state identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -321,47 +492,52 @@ def undo_edit( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: RunbookDraftUndoEditResult, or the result of cls(response) + :rtype: ~azure.mgmt.automation.models.RunbookDraftUndoEditResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = self._deserialize('RunbookDraftUndoEditResult', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized + + undo_edit.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit"} # type: ignore - undo_edit.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/undoEdit'} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py index 62717cca25ee..4b7f0afce385 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_runbook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,307 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling 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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "text/powershell" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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. @@ -47,65 +330,62 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def _publish_initial( + def _publish_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) - _publish_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + _publish_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore - def begin_publish( + + @distributed_trace + def begin_publish( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Publish runbook draft. :param resource_group_name: Name of an Azure Resource group. @@ -114,16 +394,22 @@ def begin_publish( :type automation_account_name: str :param runbook_name: The parameters supplied to the publish runbook operation. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -136,25 +422,18 @@ def begin_publish( resource_group_name=resource_group_name, automation_account_name=automation_account_name, runbook_name=runbook_name, + api_version=api_version, cls=lambda x,y,z: x, **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: @@ -164,18 +443,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_publish.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish"} # type: ignore + @distributed_trace def get_content( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> IO: """Retrieve the content of runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -184,61 +463,63 @@ def get_content( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: IO, or the result of cls(response) + :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('str', pipeline_response) + deserialized = self._deserialize('IO', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_content.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content'} # type: ignore + get_content.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/content"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> "_models.Runbook": """Retrieve the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -247,6 +528,9 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -257,34 +541,31 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +574,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - parameters, # type: "_models.RunbookCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + parameters: "_models.RunbookCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Runbook": """Create the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -315,6 +598,9 @@ def create_or_update( :param parameters: The create or update parameters for runbook. Provide either content link for a published runbook or draft, not both. :type parameters: ~azure.mgmt.automation.models.RunbookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -325,39 +611,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +652,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - parameters, # type: "_models.RunbookUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Runbook" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + parameters: "_models.RunbookUpdateParameters", + **kwargs: Any + ) -> "_models.Runbook": """Update the runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -391,6 +675,9 @@ def update( :type runbook_name: str :param parameters: The update parameters for runbook. :type parameters: ~azure.mgmt.automation.models.RunbookUpdateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Runbook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Runbook @@ -401,39 +688,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RunbookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +725,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Delete the runbook by name. :param resource_group_name: Name of an Azure Resource group. @@ -460,6 +745,9 @@ def delete( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -470,94 +758,96 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RunbookListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.RunbookListResult"]: """Retrieve a list of runbooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RunbookListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.RunbookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RunbookListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -566,17 +856,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py index 6bd51aca5617..3b120b57172b 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_schedule_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,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. @@ -64,6 +271,9 @@ def create_or_update( :type schedule_name: str :param parameters: The parameters supplied to the create or update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule or None @@ -74,39 +284,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +326,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - parameters, # type: "_models.ScheduleUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + parameters: "_models.ScheduleUpdateParameters", + **kwargs: Any + ) -> "_models.Schedule": """Update the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -141,6 +349,9 @@ def update( :type schedule_name: str :param parameters: The parameters supplied to the update schedule operation. :type parameters: ~azure.mgmt.automation.models.ScheduleUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule @@ -151,39 +362,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduleUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduleUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + schedule_name=schedule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +399,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Schedule" + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + **kwargs: Any + ) -> "_models.Schedule": """Retrieve the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -210,6 +419,9 @@ def get( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Schedule, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Schedule @@ -220,34 +432,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +465,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + schedule_name: str, + **kwargs: Any + ) -> None: """Delete the schedule identified by schedule name. :param resource_group_name: Name of an Azure Resource group. @@ -274,6 +485,9 @@ def delete( :type automation_account_name: str :param schedule_name: The schedule name. :type schedule_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -284,94 +498,96 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules/{scheduleName}"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduleListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.ScheduleListResult"]: """Retrieve a list of schedules. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ScheduleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.ScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -380,17 +596,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/schedules"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py index 8fcd0a1009c4..539769f9b16d 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_machine_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationMachineRunId": _SERIALIZER.url("software_update_configuration_machine_run_id", software_update_configuration_machine_run_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + _url = _format_url_section(_url, **path_format_arguments) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # 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 +137,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. @@ -62,8 +155,11 @@ def get_by_id( :param software_update_configuration_machine_run_id: The Id of the software update configuration machine run. :type software_update_configuration_machine_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRun @@ -74,36 +170,32 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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,35 +204,41 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns/{softwareUpdateConfigurationMachineRunId}"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - skip=None, # type: Optional[str] - top=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationMachineRunListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any + ) -> "_models.SoftwareUpdateConfigurationMachineRunListResult": """Return list of software update configuration machine runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: number of entries you skip before returning results. + :param skip: number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationMachineRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationMachineRunListResult @@ -151,41 +249,34 @@ 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +285,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationMachineRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py index 229b49a5ca4f..468056863685 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configuration_runs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationRunId": _SERIALIZER.url("software_update_configuration_run_id", software_update_configuration_run_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + _url = _format_url_section(_url, **path_format_arguments) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # 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 +137,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. @@ -61,8 +154,11 @@ def get_by_id( :type automation_account_name: str :param software_update_configuration_run_id: The Id of the software update configuration run. :type software_update_configuration_run_id: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRun, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRun @@ -73,36 +169,32 @@ 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') + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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,35 +203,41 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}'} # type: ignore + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns/{softwareUpdateConfigurationRunId}"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - skip=None, # type: Optional[str] - top=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationRunListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + skip: Optional[str] = None, + top: Optional[str] = None, + **kwargs: Any + ) -> "_models.SoftwareUpdateConfigurationRunListResult": """Return list of software update configuration runs. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str :param filter: The filter to apply on the operation. You can use the following filters: 'properties/osType', 'properties/status', 'properties/startTime', and - 'properties/softwareUpdateConfiguration/name'. + 'properties/softwareUpdateConfiguration/name'. Default value is None. :type filter: str - :param skip: Number of entries you skip before returning results. + :param skip: Number of entries you skip before returning results. Default value is None. :type skip: str - :param top: Maximum number of entries returned in the results collection. + :param top: Maximum number of entries returned in the results collection. Default value is + None. :type top: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationRunListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationRunListResult @@ -150,41 +248,34 @@ 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + skip=skip, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +284,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurationRuns"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py index 2c1b164f8096..c971af9aea0e 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_software_update_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "softwareUpdateConfigurationName": _SERIALIZER.url("software_update_configuration_name", software_update_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2019-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +223,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. @@ -65,8 +244,11 @@ def create( :type software_update_configuration_name: str :param parameters: Request body. :type parameters: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration @@ -77,41 +259,36 @@ 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) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + 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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -124,17 +301,19 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace def get_by_name( self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfiguration" + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.SoftwareUpdateConfiguration": """Get a single software update configuration by name. :param resource_group_name: Name of an Azure Resource group. @@ -144,8 +323,11 @@ def get_by_name( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfiguration, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfiguration @@ -156,36 +338,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +372,19 @@ def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore - def delete( + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - software_update_configuration_name, # type: str - client_request_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + software_update_configuration_name: str, + client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: """delete a specific software update configuration. :param resource_group_name: Name of an Azure Resource group. @@ -214,8 +394,11 @@ def delete( :param software_update_configuration_name: The name of the software update configuration to be created. :type software_update_configuration_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -226,62 +409,62 @@ 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: 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, + api_version=api_version, + client_request_id=client_request_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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - automation_account_name, # type: str - client_request_id=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SoftwareUpdateConfigurationListResult" + resource_group_name: str, + automation_account_name: str, + client_request_id: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> "_models.SoftwareUpdateConfigurationListResult": """Get all software update configurations for the account. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param client_request_id: Identifies this specific client request. + :param client_request_id: Identifies this specific client request. Default value is None. :type client_request_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SoftwareUpdateConfigurationListResult, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SoftwareUpdateConfigurationListResult @@ -292,37 +475,32 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + api_version=api_version, + client_request_id=client_request_id, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +509,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py index 86678aad8385..3c7a399cec73 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,233 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +256,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. @@ -64,6 +275,9 @@ def create_or_update( :type source_control_name: str :param parameters: The parameters supplied to the create or update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -74,39 +288,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +329,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - parameters, # type: "_models.SourceControlUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControl" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + parameters: "_models.SourceControlUpdateParameters", + **kwargs: Any + ) -> "_models.SourceControl": """Update a source control. :param resource_group_name: Name of an Azure Resource group. @@ -140,6 +352,9 @@ def update( :type source_control_name: str :param parameters: The parameters supplied to the update source control operation. :type parameters: ~azure.mgmt.automation.models.SourceControlUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -150,39 +365,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SourceControlUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +402,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + **kwargs: Any + ) -> None: """Delete the source control. :param resource_group_name: Name of an Azure Resource group. @@ -209,6 +422,9 @@ def delete( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -219,49 +435,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControl" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + **kwargs: Any + ) -> "_models.SourceControl": """Retrieve the source control identified by source control name. :param resource_group_name: Name of an Azure Resource group. @@ -270,6 +484,9 @@ def get( :type automation_account_name: str :param source_control_name: The name of source control. :type source_control_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControl, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControl @@ -280,34 +497,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControl', pipeline_response) @@ -316,66 +530,73 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SourceControlListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SourceControlListResult"]: """Retrieve a list of source controls. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlListResult or the result of cls(response) + :return: An iterator like instance of either SourceControlListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -384,17 +605,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py index 8171b1602c8a..253e82499f50 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +178,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. @@ -67,6 +200,9 @@ def create( :type source_control_sync_job_id: str :param parameters: The parameters supplied to the create source control sync job operation. :type parameters: ~azure.mgmt.automation.models.SourceControlSyncJobCreateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJob @@ -77,40 +213,36 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SourceControlSyncJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SourceControlSyncJob', pipeline_response) @@ -119,17 +251,19 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControlSyncJobById" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + **kwargs: Any + ) -> "_models.SourceControlSyncJobById": """Retrieve the source control sync job identified by job id. :param resource_group_name: Name of an Azure Resource group. @@ -140,6 +274,9 @@ def get( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobById @@ -150,35 +287,32 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +321,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SourceControlSyncJobListResult"] + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SourceControlSyncJobListResult"]: """Retrieve a list of source control sync jobs. :param resource_group_name: Name of an Azure Resource group. @@ -206,51 +342,58 @@ def list_by_automation_account( :type automation_account_name: str :param source_control_name: The source control name. :type source_control_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] + :return: An iterator like instance of either SourceControlSyncJobListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -259,17 +402,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py index fb7d88085d3a..628d90304c6c 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_source_control_sync_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "sourceControlSyncJobId": _SERIALIZER.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), + "streamId": _SERIALIZER.url("stream_id", stream_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _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 +133,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. @@ -65,52 +153,60 @@ def list_by_sync_job( :type source_control_name: str :param source_control_sync_job_id: The source control sync job id. :type source_control_sync_job_id: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] + :return: An iterator like instance of either SourceControlSyncJobStreamsListBySyncJob or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.SourceControlSyncJobStreamsListBySyncJob] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlSyncJobStreamsListBySyncJob"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sync_job.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'sourceControlName': self._serialize.url("source_control_name", source_control_name, 'str'), - 'sourceControlSyncJobId': self._serialize.url("source_control_sync_job_id", source_control_sync_job_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sync_job_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + source_control_name=source_control_name, + source_control_sync_job_id=source_control_sync_job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_sync_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -119,31 +215,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_sync_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams'} # type: ignore + list_by_sync_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - source_control_name, # type: str - source_control_sync_job_id, # type: str - stream_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SourceControlSyncJobStreamById" + resource_group_name: str, + automation_account_name: str, + source_control_name: str, + source_control_sync_job_id: str, + stream_id: str, + **kwargs: Any + ) -> "_models.SourceControlSyncJobStreamById": """Retrieve a sync job stream identified by stream id. :param resource_group_name: Name of an Azure Resource group. @@ -156,6 +257,9 @@ def get( :type source_control_sync_job_id: str :param stream_id: The id of the sync job stream. :type stream_id: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SourceControlSyncJobStreamById, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.SourceControlSyncJobStreamById @@ -166,36 +270,33 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +305,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/sourceControls/{sourceControlName}/sourceControlSyncJobs/{sourceControlSyncJobId}/streams/{streamId}"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py index 2c4886e9945d..68b5da5e6166 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_statistics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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,64 +87,69 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StatisticsListResult or the result of cls(response) + :return: An iterator like instance of either StatisticsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.StatisticsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.StatisticsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -111,17 +158,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/statistics"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py index 143df34ab9bc..5b67f49c4caf 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,222 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +245,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. @@ -63,6 +264,9 @@ def create( :type runbook_name: str :param parameters: The parameters supplied to the create test job operation. :type parameters: ~azure.mgmt.automation.models.TestJobCreateParameters + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob @@ -73,39 +277,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TestJobCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestJob', pipeline_response) @@ -114,16 +314,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TestJob" + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> "_models.TestJob": """Retrieve the test job for the specified runbook. :param resource_group_name: Name of an Azure Resource group. @@ -132,6 +334,9 @@ def get( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TestJob, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.TestJob @@ -142,34 +347,31 @@ 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +380,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob'} # type: ignore - def resume( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob"} # type: ignore + + + @distributed_trace + def resume( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Resume the test job. :param resource_group_name: Name of an Azure Resource group. @@ -196,6 +400,9 @@ def resume( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -206,49 +413,47 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.resume.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - resume.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume'} # type: ignore + resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/resume"} # type: ignore - def stop( + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Stop the test job. :param resource_group_name: Name of an Azure Resource group. @@ -257,6 +462,9 @@ def stop( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -267,49 +475,47 @@ 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/stop"} # type: ignore + - def suspend( + @distributed_trace + def suspend( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + **kwargs: Any + ) -> None: """Suspend the test job. :param resource_group_name: Name of an Azure Resource group. @@ -318,6 +524,9 @@ def suspend( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -328,37 +537,35 @@ 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') - - # 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) + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + template_url=self.suspend.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - suspend.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend'} # type: ignore + suspend.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/suspend"} # type: ignore + diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py index 0b45b5c214e1..a0cfd98dec33 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_test_job_streams_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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_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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + "jobStreamId": _SERIALIZER.url("job_stream_id", job_stream_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2018-06-30") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "runbookName": _SERIALIZER.url("runbook_name", runbook_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _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') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # 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 +129,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. @@ -64,6 +148,9 @@ def get( :type runbook_name: str :param job_stream_id: The job stream id. :type job_stream_id: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobStream, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.JobStream @@ -74,35 +161,32 @@ 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') + api_version = kwargs.pop('api_version', "2018-06-30") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +195,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams/{jobStreamId}"} # type: ignore + + + @distributed_trace def list_by_test_job( self, - resource_group_name, # type: str - automation_account_name, # type: str - runbook_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobStreamListResult"] + resource_group_name: str, + automation_account_name: str, + runbook_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.JobStreamListResult"]: """Retrieve a list of test job streams identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -130,51 +216,56 @@ def list_by_test_job( :type automation_account_name: str :param runbook_name: The runbook name. :type runbook_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2018-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobStreamListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.JobStreamListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-06-30") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.JobStreamListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_test_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'runbookName': self._serialize.url("runbook_name", runbook_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_test_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + runbook_name=runbook_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_test_job.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -183,17 +274,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_test_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams'} # type: ignore + list_by_test_job.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/draft/testJob/streams"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py index 19cf0634e982..0482f44c1fc5 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2021-06-22") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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,59 +83,63 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2021-06-22". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-22") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -106,17 +148,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/usages"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py index 5d969e664f97..b53c501419b2 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_variable_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "variableName": _SERIALIZER.url("variable_name", variable_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +252,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. @@ -64,6 +271,9 @@ def create_or_update( :type variable_name: str :param parameters: The parameters supplied to the create or update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -74,39 +284,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +325,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - parameters, # type: "_models.VariableUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Variable" + resource_group_name: str, + automation_account_name: str, + variable_name: str, + parameters: "_models.VariableUpdateParameters", + **kwargs: Any + ) -> "_models.Variable": """Update a variable. :param resource_group_name: Name of an Azure Resource group. @@ -140,6 +348,9 @@ def update( :type variable_name: str :param parameters: The parameters supplied to the update variable operation. :type parameters: ~azure.mgmt.automation.models.VariableUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -150,39 +361,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VariableUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VariableUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + variable_name=variable_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +398,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + variable_name: str, + **kwargs: Any + ) -> None: """Delete the variable. :param resource_group_name: Name of an Azure Resource group. @@ -209,6 +418,9 @@ def delete( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -219,49 +431,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - variable_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Variable" + resource_group_name: str, + automation_account_name: str, + variable_name: str, + **kwargs: Any + ) -> "_models.Variable": """Retrieve the variable identified by variable name. :param resource_group_name: Name of an Azure Resource group. @@ -270,6 +480,9 @@ def get( :type automation_account_name: str :param variable_name: The name of variable. :type variable_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Variable, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Variable @@ -280,34 +493,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Variable', pipeline_response) @@ -316,61 +526,67 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables/{variableName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VariableListResult"] + resource_group_name: str, + automation_account_name: str, + **kwargs: Any + ) -> Iterable["_models.VariableListResult"]: """Retrieve a list of variables. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VariableListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.VariableListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.VariableListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -379,17 +595,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/variables"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py index 0ced3fe30b63..b0f6c9f50143 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_watcher_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,309 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "watcherName": _SERIALIZER.url("watcher_name", watcher_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2020-01-13-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 +332,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. @@ -64,6 +351,9 @@ def create_or_update( :type watcher_name: str :param parameters: The create or update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.Watcher + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -74,39 +364,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Watcher') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +405,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Watcher" + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> "_models.Watcher": """Retrieve the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -137,6 +425,9 @@ def get( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -147,34 +438,31 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +471,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - parameters, # type: "_models.WatcherUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Watcher" + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + parameters: "_models.WatcherUpdateParameters", + **kwargs: Any + ) -> "_models.Watcher": """Update the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -204,6 +494,9 @@ def update( :type watcher_name: str :param parameters: The update parameters for watcher. :type parameters: ~azure.mgmt.automation.models.WatcherUpdateParameters + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Watcher, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Watcher @@ -214,39 +507,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WatcherUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +544,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore - def delete( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Delete the watcher by name. :param resource_group_name: Name of an Azure Resource group. @@ -273,6 +564,9 @@ def delete( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -283,49 +577,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}"} # type: ignore + - def start( + @distributed_trace + def start( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Resume the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -334,6 +626,9 @@ def start( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -344,49 +639,47 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start'} # type: ignore + start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/start"} # type: ignore - def stop( + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - watcher_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + watcher_name: str, + **kwargs: Any + ) -> None: """Resume the watcher identified by watcher name. :param resource_group_name: Name of an Azure Resource group. @@ -395,6 +688,9 @@ def stop( :type automation_account_name: str :param watcher_name: The watcher name. :type watcher_name: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -405,99 +701,101 @@ 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') + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers/{watcherName}/stop"} # type: ignore + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WatcherListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.WatcherListResult"]: """Retrieve a list of watchers. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2020-01-13-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WatcherListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.WatcherListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-01-13-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.WatcherListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -506,17 +804,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/watchers"} # type: ignore diff --git a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py index 8f6548f69bc4..af1a42387a03 100644 --- a/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py +++ b/sdk/automation/azure-mgmt-automation/azure/mgmt/automation/operations/_webhook_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,269 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat 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 = kwargs.pop('api_version', "2015-10-31") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2015-10-31") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2015-10-31") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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: + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "webhookName": _SERIALIZER.url("webhook_name", webhook_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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 = kwargs.pop('api_version', "2015-10-31") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + "automationAccountName": _SERIALIZER.url("automation_account_name", automation_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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,19 +292,22 @@ 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. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: str, or the result of cls(response) :rtype: str @@ -68,33 +318,30 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +350,18 @@ def generate_uri( return cls(pipeline_response, deserialized, {}) return deserialized - generate_uri.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri'} # type: ignore - def delete( + generate_uri.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/generateUri"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + **kwargs: Any + ) -> None: """Delete the webhook by name. :param resource_group_name: Name of an Azure Resource group. @@ -121,6 +370,9 @@ def delete( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -131,49 +383,47 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + **kwargs: Any + ) -> "_models.Webhook": """Retrieve the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -182,6 +432,9 @@ def get( :type automation_account_name: str :param webhook_name: The webhook name. :type webhook_name: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -192,34 +445,31 @@ 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') + api_version = kwargs.pop('api_version', "2015-10-31") # type: 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, + api_version=api_version, + 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) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_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 +478,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - parameters, # type: "_models.WebhookCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + parameters: "_models.WebhookCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.Webhook": """Create the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -249,6 +501,9 @@ def create_or_update( :type webhook_name: str :param parameters: The create or update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookCreateOrUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -259,39 +514,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + 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) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 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 +555,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - automation_account_name, # type: str - webhook_name, # type: str - parameters, # type: "_models.WebhookUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Webhook" + resource_group_name: str, + automation_account_name: str, + webhook_name: str, + parameters: "_models.WebhookUpdateParameters", + **kwargs: Any + ) -> "_models.Webhook": """Update the webhook identified by webhook name. :param resource_group_name: Name of an Azure Resource group. @@ -325,6 +578,9 @@ def update( :type webhook_name: str :param parameters: The update parameters for webhook. :type parameters: ~azure.mgmt.automation.models.WebhookUpdateParameters + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Webhook, or the result of cls(response) :rtype: ~azure.mgmt.automation.models.Webhook @@ -335,39 +591,35 @@ 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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WebhookUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Webhook', pipeline_response) @@ -376,66 +628,72 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks/{webhookName}"} # type: ignore + + + @distributed_trace def list_by_automation_account( self, - resource_group_name, # type: str - automation_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WebhookListResult"] + resource_group_name: str, + automation_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.WebhookListResult"]: """Retrieve a list of webhooks. :param resource_group_name: Name of an Azure Resource group. :type resource_group_name: str :param automation_account_name: The name of the automation account. :type automation_account_name: str - :param filter: The filter to apply on the operation. + :param filter: The filter to apply on the operation. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-10-31". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebhookListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.automation.models.WebhookListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-10-31") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.WebhookListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-10-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_automation_account.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), - 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_automation_account_request( + resource_group_name=resource_group_name, + automation_account_name=automation_account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_automation_account.metadata['url'], + ) + 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, + api_version=api_version, + 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) @@ -444,17 +702,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks'} # type: ignore + list_by_automation_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/webhooks"} # type: ignore